Hi,
why might the arduino spit out lots of data (more than it should with a given delay) directly after an interrupt is called?
here's the code for anyone who is interested:
#define BOUNCE_DURATION 2000 // define an appropriate bounce time in ms for your switches
volatile unsigned long bounceTime=0; // variable to hold ms count to debounce a pressed switch
int read_val = 0;
int b = 0;
int trig = 0; //flag to control header to be printed before reads
char changer;
void setup ()
{
Serial.begin (115200);
attachInterrupt(1, trigger, CHANGE);
}
void loop () {
if (trig == 1)
{
Serial.print("read");
for (b=0; b<4; b++)
{
read_val = analogRead(b);
Serial.print(read_val,DEC);
}
changer = 'f';
delay(500);
}
if (trig == 0)
{
Serial.print("dare");
for (b=0; b<4; b++)
{
read_val = analogRead(b);
Serial.print(read_val,DEC);
}
changer = 'o';
delay(500);
}
}
void trigger ()
{
if(millis() > bounceTime)
{
if (changer == 'o')
{
trig = 1;
}
if (changer == 'f')
{
trig = 0;
}
bounceTime = millis() + BOUNCE_DURATION;
}
}