Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
11 years, 7 months ago.
i have a question about interrruptin
blow code does not work well
when i switch on, "count" doesn't change.
what the problem?
#include "mbed.h" InterruptIn input(p5); DigitalOut led1(LED1); DigitalOut led2(LED2); int count = 0; int pre = 0; void count_input(){ count++; wait(0.002); } int main() { input.mode(PullUp); input.rise(&count_input); while(1) { if(count%4 == 0){ led1 = 1; led2 = 1; } if(count%4 == 1){ led1 = 1; led2 = 0; wait(0.2); led1 = 0; led2 = 1; wait(0.2); } if(count%4 == 2){ led1 = 0; led2 = 0; } if(count%4 == 3){ led1 = 1; led2 = 0; wait(0.3); led1 = 0; led2 = 1; wait(0.3); } } }