int pinLed [9] = {12,11,10,9,8,7,6,5,4};
int numeroLed;
char digitado; // vai quarda o que tiver na porta Serial.begin(9600);
void setup() {
// put your setup code here, to run once:
int x;
for (x = 0; x <= 8; x = x + 1) {
pinMode (pinLed[x], OUTPUT);
}
Serial.begin (9600); // manter a comunicação entre Arduino e PC.
}
void loop() {
// put your main code here, to run repeatedly:
digitado = ' '; //valor neutro
numeroLed = 0;
while (digitado != 'P') { //quando o caracteri for diferente (!=) do P o programa vai continuar.
digitalWrite (pinLed[numeroLed], LOW);
numeroLed = numeroLed + 1;
if (numeroLed > 8) {
numeroLed = 0;
}
digitalWrite (pinLed[numeroLed], HIGH);
if (Serial.available()) {// identificação para fazer a leitura da porta Serial
digitado = Serial.read (); //qualquer infomação que estiver na porta Serial vai ser jogado para a Variável (digitado)
}
delay (100);
}
delay (5000);
}