Using an Arduino Uno / Latest version of IDE
I hit a bump in the road with my code so I threw one of my variables in the old serial monitor and all I get is random characters. Here is what I get every line it refreshes.
e !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_`abcdefghijklmnopqrstuvwxyz{|}~⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮
Here is my code:
like I said it isn't working correctly right now, but I don't think that is the issue.
my baud rates match between serial and code and I've tried both 9600 and 4800 for good measure.
Any suggestions?
#include "FastLED.h"
#define NUM_LEDS 2
#define DATA_PIN 9
CRGB leds[NUM_LEDS];
int hue = 0;
/////////////// Switch 1
int S1 = digitalRead(7);
int S1Val = 0;
int DtVal = 0;
/////////////////////////////////
void setup() {
Serial.begin(4800);
pinMode(7, INPUT);
pinMode(9, OUTPUT);
FastLED.addLeds<WS2811, DATA_PIN, RGB>(leds, NUM_LEDS);
delay(500);
START();
delay(500);
}
void loop() {
EVERY_N_MILLISECONDS(200) {
DtVal = 0;
}
SWITCH1();
///////////////////////// BASIC COLORS (ON SWITCH 1)
hue = S1Val;
CHSV color = CHSV(hue, 255, 50);
fill_solid(leds, NUM_LEDS, color);
FastLED.show();
Serial.write(S1Val);
////////////////////////// switch reset
SWITCH1RESET();
}
/////////////////////////// END OF LOOP
void START()
{
fill_solid(leds, NUM_LEDS, CRGB(150, 0, 0));
FastLED.show();
delay(200);
fill_solid(leds, NUM_LEDS, CRGB(0, 0, 0));
FastLED.show();
delay(200);
fill_solid(leds, NUM_LEDS, CRGB(150, 0, 0));
FastLED.show();
delay(200);
fill_solid(leds, NUM_LEDS, CRGB(0, 0, 0));
FastLED.show();
}
//////////////////////////// VOIDS
void SWITCH1RESET()
{ if (S1Val > 255) {
S1Val = 0;
}
}
void OFF()
{ fill_solid(leds, NUM_LEDS, CRGB(0, 0, 0));
FastLED.show();
}
void SWITCH1()
{
if (S1 == 0) {
S1Val++;
}
}
void DOUBLETAP()
{ DtVal = digitalRead(7);
if (DtVal == 2) {
S1Val = 0;
}
}