Brian Tilton
/
BTilton-Lab2_Joystick_Interupt
Lab2_Part3 working
Fork of Bootcamp-Interrupt_Polling_Joystick by
main.cpp
- Committer:
- Cabal51
- Date:
- 2013-10-11
- Revision:
- 3:22fdf3a4be19
- Parent:
- 2:d18857b99d3c
File content as of revision 3:22fdf3a4be19:
#include "mbed.h" // // ignore interrupt version till we discuss that topic // #ifdef INTERRUPT InterruptIn fire(p14); DigitalOut led(LED1); DigitalOut flash(LED4); void ISR1() { led = !led; } int main() { fire.rise(&ISR1); fire.fall(&ISR1); while (1) { flash = !flash; wait(0.25); } } #endif #include "mbed.h" #include "C12832_lcd.h" C12832_LCD lcd; BusIn joy(p15,p12,p13,p16); InterruptIn fire(p14); BusOut leds(LED1,LED2,LED3,LED4); int main() { while(1) { if (fire) { leds=0xf; lcd.cls(); lcd.locate(0,0); lcd.printf("\n\rFIRE = ON "); } else { leds=joy; if(joy == 0x8){ lcd.cls(); lcd.locate(0,0); lcd.printf("\n\rRIGHT = ON "); } else if(joy == 0x4){ lcd.cls(); lcd.locate(0,0); lcd.printf("\n\rLEFT = ON "); } else if(joy == 0x2){ lcd.cls(); lcd.locate(0,0); lcd.printf("\n\rDOWN = ON "); } else if(joy == 0x1){ lcd.cls(); lcd.locate(0,0); lcd.printf("\n\rUP = ON "); } else if(joy == 0x0){ lcd.cls(); lcd.locate(0,0); lcd.printf("\n\rNONE "); } } wait(0.1); } }