Hi Guys im a new arduino user,I d like to do a project with external interrupt.
This project should turn on 2 leds, one in digital port 13, and another in digital port 12, with press the interrupt extern 0 to led 13 or press interrupt extern 1 to led 12.
Look my code:
strange
const int botaoverde = 0;
const int botaoamarelo = 1;
const int led1 = 13;
const int led2 = 12;
volatile int flag1 = LOW;
volatile int flag2 = LOW;
void setup(){
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
attachInterrupt(botaoverde, tratador1, CHANGE);
attachInterrupt(botaoamarelo, tratador2, CHANGE);
}
void loop(){
digitalWrite(led1,flag1);
digitalWrite(led2,flag2);
}
void tratador1(){
flag1= !flag1;
}
void tratador2(){
flag2= !flag2;
}
look my "circuit"
i have a strange error or bug. when i turn on my arduino with the code the leds turn on, turn off, i dont know why this occur.
if i touth on anywhere the interrupt are a thrown!!!!
help me plz
arduino.bmp (321 KB)