Here are my codes:
int BlueLED=9; //define blue red pin at 9
int BlueLEDontime=100;
int BlueLEDofftime=500;
int RedLED=7;
int RedLEDontime=100;
int RedLEDofftime=500;
int numBlueblink;
int numRedblink;
String Bluemesssage="The Blue is Blinking!";
String Redmessage="The Red is Blinking!";
void setup() {
Serial.begin(115200);
String wm1= "Welcome to ";
String wm2= "my program";
String wm3=wm1+wm2;
Serial.print(wm3);
Serial.println(" ");
pinMode(BlueLED,OUTPUT);
pinMode(RedLED,OUTPUT);
Serial.println("Please input the bluelink times?");
while (Serial.available()==0) { }
numBlueblink=Serial.parseInt();
Serial.println("Please input the redblink times?");
while (Serial.available()==0) { }
numRedblink=Serial.parseInt();
}
void loop() {
Serial.println(Bluemesssage);
for (int j=1;j<=numBlueblink; j=j+1) {
Serial.print("You are on blink #:");
Serial.println(j);
digitalWrite(BlueLED,HIGH);
delay(BlueLEDontime);
digitalWrite(BlueLED,LOW);
delay(BlueLEDofftime);
}
Serial.println(" ");
Serial.println(Redmessage);
for (int i=1;i<=numRedblink; i=i+1) {
Serial.print("You are on blink #:");
Serial.println(i);
digitalWrite(RedLED,HIGH);
delay(RedLEDontime);
digitalWrite(RedLED,LOW);
delay(RedLEDofftime);
}
Serial.println(" ");
Here is what shows in my monitor:
Welcome to my program
Please input the bluelink times? (I did input 2 at here).
Please input the redblink times?
The Blue is Blinking!
You are on blink #:1
You are on blink #:2
The Red is Blinking!
The Blue is Blinking!
You are on blink #:1
You are on blink #:2
The Red is Blinking!
The Blue is Blinking!
You are on blink #:1
You are on blink #:2
The Red is Blinking!
The Blue is Blinking!
You are on blink #:1
You are on blink #:2
I hope the interface ask me input the number for redblink. But it doesn't. Don't know why.