0
my code on the Arduino
void setup() {
// put your setup code here, to run once:
int pinoMotor = 11;
int pinoBotao = 12;
int on = 0;
int estadoBotao;
pinMode(pinoMotor, OUTPUT);
pinMode(pinoBotao, INPUT);
}
void loop() {
// put your main code here, to run repeatedly:
estadoBotao = digitalRead(pinoBotao);
if (estadoBotao == HIGH) {
if(on == 1)
{on = 0;}
else{on = 1;}
}
if ( on ==1)
{digitalWrite (pinoMotor, HIGH);
}
else {digitalWrite (pinoMotor, LOW);}
delay (100);
Well, when I compile this code, in the command line state Otao = digitalRead(pinoBotao); message comes out:
'stateBotao' was not declared in the Scope
Declare your 4 variables outside of the functions. Otherwise, they will only be accessible within the function where they were declared (in this case,
setup
).– bfavaretto
bfavaretto I did what you commented to put when I declare the variaves before the void setup, a new error msg appears "Compiling error for the Arduino Uno board"
– Joel Machado