right after my first while loop I enter numRedBlink the arduino isn't recognizing it. my error code says numRedBlink does not name a type. But in following this programmer on youtube learning what I can and on his arduino uno it recognized it. heres my code maybe you can help.
int redLedPin=9; //Declaring red led as an int, and set to 9:
int yellowLedPin=10; // Declaring yellow led as an int, and set to 10:
int redOnTime=250; //Red led is on 250:
int redOffTime=250; // Red led is off 250:
int yellowOnTime=250; // Yellow led is on 250:
int yellowOffTime=250; // Yellow led is off 250:
int numRedBlink; // declaring a variable
int numYellowBlink; // declaring a variable
String redMessage= "the red led is blinking"; // declaring a string variable
String yellowMessage= "the yellow led is blinking"; // declaring a string variable
void setup() {
Serial.begin(9600);
String wm1 ="hello nicholas "; // declare string variable
String wm2="its your program";
String wm3; // declare a sting variable
wm3=wm1+wm2; //concatenation take wm1+wm2=wm3
Serial.println(wm3);
pinMode(redLedPin,OUTPUT);
pinMode(yellowLedPin,OUTPUT);
}
void loop() {
Serial.println("How Many Times I Want Red LED To Blink"); // asking
while (Serial.available()==0) { } // wait for input.
}
numRedBlink=Serial.parseInt();
Serial.println("How Many Times I Want Red LED To Blink"); // asking
while [Serial.available()==0] { } // wait for input
}
numYellowBlink=Serial.parseInt();
int c=c+1;
Serial.println(redMessage);
for (c=1; c<=numRedBlink; c=c+1){ // starting for loop
Serial.print("I am Awsome");
Serial.println(c);
digitalWrite(redLedPin,HIGH); // turn the red led on:
delay(redOffTime); // wait:
digitalWrite(redLedPin,LOW); // turn the red led off:
delay(redOffTime); //Wait:
}
Serial.println(" ");
Serial.println(yellowMessage);
for (int c=1; c<=numYellowBlink; c=c+1){
Serial.print("i am awsome");
Serial.println(c);
digitalWrite(yellowLedPin,HIGH); //turn the yellow led on:
delay(yellowOffTime); //Wait:
digitalWrite(yellowLedPin,LOW); //turn the yellow led off:
delay(yellowOffTime); //Wait:
Serial.println(" ");
}
}
you can try this. I don't know if it does what you expect but it will compile.
int redLedPin = 9; //Declaring red led as an int, and set to 9:
int yellowLedPin = 10; // Declaring yellow led as an int, and set to 10:
int redOnTime = 250; //Red led is on 250:
int redOffTime = 250; // Red led is off 250:
int yellowOnTime = 250; // Yellow led is on 250:
int yellowOffTime = 250; // Yellow led is off 250:
int numRedBlink; // declaring a variable
int numYellowBlink; // declaring a variable
String redMessage = "the red led is blinking"; // declaring a string variable
String yellowMessage = "the yellow led is blinking"; // declaring a string variable
void setup() {
Serial.begin(9600);
String wm1 = "hello nicholas "; // declare string variable
String wm2 = "its your program";
String wm3; // declare a sting variable
wm3 = wm1 + wm2; //concatenation take wm1+wm2=wm3
Serial.println(wm3);
pinMode(redLedPin, OUTPUT);
pinMode(yellowLedPin, OUTPUT);
}
void loop() {
Serial.println("How Many Times I Want Red LED To Blink"); // asking
while (Serial.available() == 0) { // wait for input.
}
numRedBlink = Serial.parseInt();
Serial.println("How Many Times I Want Red LED To Blink"); // asking
while (Serial.available() == 0) { // wait for input
}
numYellowBlink = Serial.parseInt();
int c = c + 1;
Serial.println(redMessage);
for (c = 1; c <= numRedBlink; c = c + 1) { // starting for loop
Serial.print("I am Awsome");
Serial.println(c);
digitalWrite(redLedPin, HIGH); // turn the red led on:
delay(redOffTime); // wait:
digitalWrite(redLedPin, LOW); // turn the red led off:
delay(redOffTime); //Wait:
}
Serial.println(" ");
Serial.println(yellowMessage);
for (int c = 1; c <= numYellowBlink; c = c + 1) {
Serial.print("i am awsome");
Serial.println(c);
digitalWrite(yellowLedPin, HIGH); //turn the yellow led on:
delay(yellowOffTime); //Wait:
digitalWrite(yellowLedPin, LOW); //turn the yellow led off:
delay(yellowOffTime); //Wait:
Serial.println(" ");
}
}