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
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy