I am an absolute noob who has literally got around 10 hours of experience. so please forgive my ignorance.
I am currenty making a railway signal 4 aspect (4leds)....ive got everything working as it should via bluetooth app, all working individually and also in sequence going through the light sequence.....however in (case 5), how do i get it to keep looping until another case is received from bluetooth?....it is only doing it once but i would like it to keep looping until another case is inputed.....im positive it is really simple, but as i said im totally new.
thanks in advance.
will
void setup() {
Serial.begin(9600);
pinMode(8, OUTPUT); //red led (case 1)
pinMode(9, OUTPUT); //singleyellow led (case 2)
pinMode(10, OUTPUT); //twoyellows led (case 3)
pinMode(11, OUTPUT);//green led (case 4)
// (case 5 led sequence)
}
void loop() {
// put your main code here, to run repeatedly:
if(Serial.available()>0)
{
char data= Serial.read(); // reading the data received from the bluetooth module
switch(data)
{
case '1': digitalWrite(8, HIGH);
digitalWrite(9, LOW);
digitalWrite(10, LOW);
digitalWrite(11, LOW);break; // when red is pressed on the app on your smart phone
case '2': digitalWrite(8, LOW);
digitalWrite(9, HIGH);
digitalWrite(10, LOW);
digitalWrite(11, LOW);break; // when yellow is pressed on the app on your smart phone
case '3': digitalWrite(8, LOW);
digitalWrite(9, HIGH);
digitalWrite(10, HIGH);
digitalWrite(11, LOW);break; // when twoyellow is pressed on the app on your smart phone
case '4': digitalWrite(8, LOW);
digitalWrite(9, LOW);
digitalWrite(10, LOW);
digitalWrite(11, HIGH);break; // when green is pressed on the app on your smart phone
case '5': digitalWrite(8, HIGH);
digitalWrite(9, LOW);
digitalWrite(10, LOW);
digitalWrite(11, LOW);
delay (5000);
digitalWrite(8, LOW);
digitalWrite(9, HIGH);
digitalWrite(10, LOW);
digitalWrite(11, LOW);
delay (5000);
digitalWrite(8, LOW);
digitalWrite(9, HIGH);
digitalWrite(10, HIGH);
digitalWrite(11, LOW);
delay (5000);
digitalWrite(8, LOW);
digitalWrite(9, LOW);
digitalWrite(10, LOW);
digitalWrite(11, HIGH)
delay(5000);break; // sequence
}
Serial.println(data);
}
delay(50);
}