Hello
I am an Arduno beginner.
I am trying to get 2 LEDs working with different blinking times through for loop
The program is working fine with no problem.
However, when I add the Serial.begin(baud rate) One of the LEDs (yellow) is constantly turned on and not blinking.
When this Serial.begin command is disabled, the LED is blinking as it should
Any reason for that?
Is related to the OS : Windows 10. I also work with the latest Arduino version
I appreciate any help
Thanks
Here is the code:
int redLED = 3;
int yellowLED = 1;
int waitTimeonRed= 100;
int waitTimeoffRed= 1000;
int waitTimeonYellow= 100;
int waitTimeoffYellow= 1000;
int numRedBlink= 3;
int numYellowBlink= 2;
void setup() {
Serial.begin(9600);
pinMode(redLED,OUTPUT);
pinMode(yellowLED,OUTPUT);
}
void loop () {
// put your main code here, to run repeatedly:
Serial.println(" The Red LED is Blinking");
for (int j = 1; j<=numRedBlink; j=j+1) {
Serial.print(" You are in Blink No.: ");
Serial.println(j);
digitalWrite(redLED,HIGH);
delay(waitTimeonRed);
digitalWrite(redLED,LOW);
delay(waitTimeoffRed);
}
Serial.println(" ");
Serial.println(" The yellow LED is Blinking");
for (int j = 1; j<=numYellowBlink; j=j+1) {
Serial.print(" You are in Blink No.: ");
Serial.println(j);
digitalWrite(yellowLED,HIGH);
delay(waitTimeonYellow);
digitalWrite(yellowLED,LOW);
delay(waitTimeoffYellow);
}
Serial.println(" ");
}