Hi there, I am new to Arduino and coding in general. I am using an HC-05 module to communicate with my phone. I'm fairly sure there is something illogical about this code but I cant figure out what.
any help will be greatly appreciated.
#define LED1pin 4
#define LED2pin 5
bool Led1;
bool Led2;
void setup() {
Serial.begin(9600);
pinMode(LED1pin, OUTPUT);
pinMode(LED2pin, OUTPUT);
}
void loop(){
UpdateInstructions();
if (Led1 == true){digitalWrite( LED1pin, HIGH);digitalWrite( LED2pin, LOW);}
else if (Led2 == true){digitalWrite( LED2pin, HIGH);digitalWrite( LED1pin, LOW);}
}
void UpdateInstructions(){
if(Serial.available()){
char ReadChar = Serial.read();
if (ReadChar == 'm'){ Led1 = true; Led2 = false;}
else if (ReadChar == 'a'){Led2 = true; Led1 = false;}
}
}