Tj Maher
/
Lab1-2DigitalInterrupts
toggle the joystick and print the results
main.cpp
- Committer:
- t00203959
- Date:
- 2019-05-22
- Revision:
- 0:5b8d5174372e
File content as of revision 0:5b8d5174372e:
#include "mbed.h" Serial pc(USBTX,USBRX); InterruptIn left(p13); InterruptIn down(p12); InterruptIn right(p16); InterruptIn up(p15); InterruptIn centre(p14); void Down() { pc.printf("Down\n"); wait_ms(75);//added wait command to eliminate the repeated operation of the function before the voltage is fixed } void Left() { pc.printf("Left\n"); wait_ms(75); } void Centre() { pc.printf("Centre\n"); wait_ms(75); } void Up() { pc.printf("Up\n"); wait_ms(75); } void Right() { pc.printf("Right\n"); wait_ms(75); } int main() { while(1) { wait (5); down.rise(&Down); left.rise(&Left); centre.rise(&Centre); up.rise(&Up); right.rise(&Right); down.rise(&Down); wait(5); } }