Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- volatile unsigned int count = 0;
- volatile int flag = 0;
- void setup()
- {
- Serial.begin(38400);
- attachInterrupt(0, isr, FALLING); //INTERRUPT 0 IS PIN D2
- }
- void loop()
- {
- if (flag == 1)
- {
- Serial.println(count);
- flag = 0;
- }
- }
- void isr()
- {
- count += 1;
- flag = 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement