Cannot get interrupts working
i have been trying create program awakens board low power state. there lot written subject not implement because not interrupts work properly.
i tried copying , pasting simple blinking led light interrupt program on arduino site found not work either.
i wrote simple program triggers arduino go in , out of low power mode when button pushed. can arduino enter sleep mode can not awaken interrupt.
i tried copying , pasting simple blinking led light interrupt program on arduino site found not work either.
i wrote simple program triggers arduino go in , out of low power mode when button pushed. can arduino enter sleep mode can not awaken interrupt.
code: [select]
#include <keypad.h>
#include <avr/sleep.h>
const byte rows = 4; //four rows
const byte cols = 3; //three columns
char keys[rows][cols] = {
{'1', '2', '3'},
{'4', '5', '6'},
{'7', '8', '9'},
{'*', '0', '#'}
};
byte rowpins[rows] = {8, 7, 6, 5}; //connect row pinouts of keypad
byte colpins[cols] = {4, 3, 2}; //connect column pinouts of keypad
keypad keypad = keypad( makekeymap(keys), rowpins, colpins, rows, cols );
void setup() {
serial.begin(9600);
serial.println("start");
pinmode(13, output);
digitalwrite(13, low);
}
void blink_isr() {
detachinterrupt(digitalpintointerrupt(2));
sleep_disable();
}
void gotosleep() {
serial.print("gotosleep");
sleep_enable();
attachinterrupt(digitalpintointerrupt(2), blink_isr, rising);
set_sleep_mode(sleep_mode_pwr_down);
digitalwrite(13, high);
sleep_mode();
/* wake here */
sleep_disable();
digitalwrite(13, low);
}
void loop() {
char key = keypad.getkey();
if (key == '#') {
gotosleep();
}
}
Arduino Forum > Using Arduino > Programming Questions > Cannot get interrupts working
arduino
Comments
Post a Comment