i have typed this code following a person on youtube and want it to show welcome to on the serial print. Why wont this work?? His has worked. This is a link to his website so you can see his code and compare it.
http://www.toptechboy.com/arduino/arduino-lesson-5-working-with-strings/
This is all of my code:
int blueLEDpin=11;
int blueWaitTimeOn=900;
int blueWaitTimeOff=100;
int redLEDPin=13;
int redWaitTimeOn=100;
int redWaitTimeOff=900;
int numBlueBlink=10; //number of times the blue LED blinks
int numRedBlink =5; // number of times thered LED blinks
String blueMessage="The blue led is blinking!"; //declaring a string variable
String redMessage="The red LED is blinking!"; //declaring the string variable
void setup() {
String st1= "Welcome to"; //declaring string variable va1 and assign a value
String st2= "my program"; //decaring string variable va2 and assign a value
Serial.print(st1);
Serial.begin(9600);
pinMode(blueLEDpin,OUTPUT);
pinMode(redLEDPin,OUTPUT);
}
void loop() {
Serial.println(blueMessage);
for (int j=1;j<=numBlueBlink; j++ ){ //this is a loop for blue LED to blink
Serial.println(" You are on blink #: ");
Serial.println(j);
digitalWrite(blueLEDpin,HIGH); //turns blue LED on
delay(blueWaitTimeOn); //delays the code
digitalWrite(blueLEDpin,LOW); //turns blue LED off
delay(blueWaitTimeOff); //delays the code
}
Serial.print(" ");
Serial.println(redMessage);
for (int j=1;j<=numRedBlink; j++ ){ //this is a loop for the red LED to blink
Serial.println(" You are on Blink #: ");
Serial.println(j);
digitalWrite(redLEDPin,HIGH); //turns red LED on
delay(redWaitTimeOn); //delays the code
digitalWrite(redLEDPin,LOW); //turns red LED off
delay(redWaitTimeOff); //delays the code
}
}