:o - Hi Everyone! Trying out this beautiful thing for the first time now!
I've just bought this Kit and tried to mess with the code of the second module - though it verifies Ok, it doesn't do what one would expect it to...
Well...
-
It is a simple 3 Led with 3 button setup - while the button is pressed, the led is on (worked Ok);
-
Then I messed exchanging HIGH for LOW in digitalWrite, giving as expected all the led on, turning off each one while pushing each of the 3 buttons (worked fine);
- Then I went bananas and tried to make each led blink while the assigned button is not pressed... The result is that only the Red led, on the 13th pin is blinking, and it doesn't stop when I press the button...
/*\ ** ROBOCORE ARDUINO KIT INICIANTE ** ** ** Módulo 2 ** */
const int ledPin1 = 13;
const int ledPin2 = 12;
const int ledPin3 = 11;
const int Botao1 = 2;
const int Botao2 = 3;
const int Botao3 = 4;
int EstadoBotao1 = 0;
int EstadoBotao2 = 0;
int EstadoBotao3 = 0;
void setup(){
pinMode(ledPin1, OUTPUT);
pinMode(Botao1, INPUT);
pinMode(ledPin2, OUTPUT);
pinMode(Botao2, INPUT);
pinMode(ledPin3, OUTPUT);
pinMode(Botao3, INPUT);
}
void loop(){
EstadoBotao1 = digitalRead(Botao1); EstadoBotao2 = digitalRead(Botao2); EstadoBotao3 = digitalRead(Botao3);
if (EstadoBotao1 == LOW){
digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level)
delay(30); // wait for a second
digitalWrite(13, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}
else{
digitalWrite(ledPin1, LOW);
}
if (EstadoBotao2 == LOW){
digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level)
delay(100); // wait for a second
digitalWrite(13, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}
else{
digitalWrite(ledPin3, LOW);
}
if (EstadoBotao3 == LOW){
digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level)
delay(100); // wait for a second
digitalWrite(13, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}
else{
digitalWrite(ledPin2, LOW);
}}