Go Down

Topic: Interrupts problem (Read 1 time) previous topic - next topic

saprodx

Hello!

I made the circuit from this schematic: http://arduino.cc/forum/index.php?topic=92518.0
When i want to display the microseconds of each bit, the arduino seems to crash.
Here is the code that i use:

Code: [Select]
unsigned long time = 0;
void setup()
{
  attachInterrupt(0, blink, LOW);
  Serial.begin(9600);
}
void loop()
{
}
void blink()
{
  time = micros();
  Serial.println(time);
  time = 0;
}


Any ideas?
Thank you!

Nick Gammon

Don't do serial prints inside an ISR.

http://www.gammon.com.au/interrupts
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

Nick Gammon

Also, a LOW interrupt fires continuously, causing possibly thousands of interrupts. More useful would be a FALLING interrupt.
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

saprodx


Go Up