I am trying to make a LED light strip project using FastLED however I currently don't have any LED strips to use so in order to test parts of my code I am trying to use Serial.write. When putting this into my original code I found that the serial write seemed to be spouting nonsense and wouldn't even properly run the serial.write in void setup. I tried a variety of things but still have no clue. I moved just the portion of my code responsible for the serial out into a separate file and slowly added stuff in till I had the problem repeat.
#include <FastLED.h>
#define LED_Pin 5
#define LEDnum 20
CRGB leds[LEDnum];
byte Fx = 0;
byte PreFx = 0; //to see if the effect just changed
unsigned int Frame = 0;
byte Decay = 0;
byte Attack = 0;
int RandomVals[LEDnum];
void setup() {
Serial.begin(115200);
Serial.write("Transfer Ready");
FastLED.addLeds<WS2812B, LED_Pin>(leds, LEDnum);
FastLED.setBrightness(100); //to start will probably get set to 225 eventualy
for(int i = 0; i <= 225; i++) {
RandomVals[i] = i;
}
//shuffleData();
}
void loop() {
Serial.print(Fx);
Serial.print(PreFx);
Serial.print(Decay);
Serial.print(Attack);
Serial.print(Frame);
Serial.print(RandomVals[225]);
}
void shuffleData() {
for (int i = LEDnum - 1; i > 0; i--) {
int j = random(i + 1); // Get a random index from 0 to i
int temp = RandomVals[i];
RandomVals[i] = RandomVals[j]; // Swap elements
RandomVals[j] = temp;
}
}
I it's current form the program seems to be trying to sent the first serial.write in the setup code over and over however not being able to send more then a byte of data with the serial monitor displaying "T�" over and over. If I pause the serial transmission then resume it it is able to get out "Tra�" before going back to its regular state. The problem started when I added the void command back in at the bottom of the script however Im not sure why. Originally it had a delay on it with EVERY_N_SECOND() however removed that line of code when learning FastLED can mess with some serial transmissions. Im not super versed in serial with Arduino however I have checked that the board and monitor are using the same baud rate.