Arduino Pin-Change Interrupts for Sonar
I had a very hard time figuring out how to use Pin-Change Interrupts. I found AVR documentation hard to follow, and Arduino libraries overly complicated and obfuscating. Here is an example of how to use pin-change interrupts for Arduino (mega). It may help.
Pin-Change Interrupt forum post
Bottom line:
PCICR |= 1; // enable PCI0 pin group interrupt
PCMSK0 |= 0b1100; // enable PC interrupts on arduino pins 50,51, which are in group PCI0
...
/// Pin-Change interrupt, for group PCI0 (arduino mega pins 13..10, and 50..53)
ISR(PCINT0_vect) {
// do what you need to do when one of the pins in this group changes.
// usually... check to see which pin changed here... then do something.
}
Upcoming Events
May26Sun7:00 pm HacknightHacknightMay 26 @ 7:00 pm – 10:00 pmOur twice-weekly open house. Come learn what we’re all about! This is when both members and non members are encouraged to come in and work/start/help [...]May28Tue9:00 am Coworking TuesdayCoworking TuesdayMay 28 @ 9:00 am – 5:00 pmTired of working at home alone? Come join us for Coworking Tuesday! (Formerly Wednesday)7:00 pm HacknightHacknightMay 28 @ 7:00 pm – 10:00 pmOur twice-weekly open house. Come learn what we’re all about! This is when both members and non members are encouraged to come in and work/start/help [...]Jun2Sun4:30 pm General MeetingGeneral MeetingJun 2 @ 4:30 pm – 6:00 pmThis is our combined Board and Business Meeting, it is open to the public, and is held on the first Sunday of every month (with [...]7:00 pm HacknightHacknightJun 2 @ 7:00 pm – 10:00 pmOur twice-weekly open house. Come learn what we’re all about! This is when both members and non members are encouraged to come in and work/start/help [...]Jun4Tue9:00 am Coworking TuesdayCoworking TuesdayJun 4 @ 9:00 am – 5:00 pmTired of working at home alone? Come join us for Coworking Tuesday! (Formerly Wednesday)7:00 pm HacknightHacknightJun 4 @ 7:00 pm – 10:00 pmOur twice-weekly open house. Come learn what we’re all about! This is when both members and non members are encouraged to come in and work/start/help [...]Jun9Sun7:00 pm HacknightHacknightJun 9 @ 7:00 pm – 10:00 pmOur twice-weekly open house. Come learn what we’re all about! This is when both members and non members are encouraged to come in and work/start/help [...]Jun11Tue9:00 am Coworking TuesdayCoworking TuesdayJun 11 @ 9:00 am – 5:00 pmTired of working at home alone? Come join us for Coworking Tuesday! (Formerly Wednesday)View Calendar Add Add
Contact Us
Tags
2600 air audio balloons Bubonicon camping class crafting crowdfunding DIY event events gamenight hack hackerscouts hacknight Ignite Instructables LED Linux makerscouts marblebrewery materials meeting music NMTC privacy Projects pyp recap robots screenprinting sky space steampunk SYT TechMas Terry theme trailer video welcome WordCamp WordPress Workshop




