Pages: [1]   Go Down
Author Topic: Attaching interrupts to multiple pins  (Read 244 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 34
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm trying to measure how long it takes each digital input to go from low to high. Can an Arduino Mega be programmed to have separate interrupts attached to each of its digital pins, to detect a level change? Or would you just constantly read pin values in the main loop() and check for the change there?
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 533
Posts: 26951
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Sure, you could use PCINTs on all the pins, set a flag when the interrupt occured.
Have a tight loop running that reads micros( ) when an interrupt occurs, note which interrupt it was, and clear the flag.
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Dubai, UAE
Offline Offline
Edison Member
*
Karma: 22
Posts: 1675
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Short overview of pinchange interrupts using the pinchangeint library here -

http://rcarduino.blogspot.com/2012/03/need-more-interrupts-to-read-more.html

Duane B

rcarduino.blogspot.com
Logged


Offline Offline
Newbie
*
Karma: 0
Posts: 34
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks CrossRoads and DuaneB.
Logged

Pages: [1]   Go Up
Jump to: