Hi all, I am making a 3x3 stage blinder and want to make it do some patterns , the electrical part is all tested and works great (triacs with optocapler to turn the 220v bulbs via the 5v arduino outs) , now I have problems with the code:
- It will be controlled via a computer COM port, I have made this work, but only one letter sent= one pin goes on or off, I want to know how to make it go to a loop when it receives something from the computer, for example if I send letter b it will go to a loop that blinks all the bulbs? This is the code so instead of digital write(9,HIGH) some goto or something similar to go to a loop ?
void setup ()
{
pinMode(9,OUTPUT);
digitalWrite(9,LOW);
Serial.begin(9600);
}
void loop()
{
if(Serial.available() > 0 )
{
char letter = Serial.read();
if(letter == '1')
{digitalWrite(9,HIGH);
}
else if(letter == '0')
{
digitalWrite(9,LOW) ;
}
}
}
- how to make the loop repeat itself until it receives something else and how to stop it in the middle of execution ? So can the loop look like turn pins pins from 1 to 5 in a sequence on and off with delays between, repeat that until you get some other signal , and if you get the signal before you get to pin 3 stop, and go to some other loop ?
sorry if these are some trivial questions, but I am fairly new to this and cant figure this out