Lab2_Part3 working

Dependencies:   C12832_lcd mbed

Fork of Bootcamp-Interrupt_Polling_Joystick by avnish aggarwal

Committer:
Cabal51
Date:
Fri Oct 11 04:51:13 2013 +0000
Revision:
3:22fdf3a4be19
Parent:
2:d18857b99d3c
Lab2 Part3 Working

Who changed what in which revision?

UserRevisionLine numberNew contents of line
avnisha 1:102ef7d39407 1
avnisha 1:102ef7d39407 2 #include "mbed.h"
avnisha 1:102ef7d39407 3
avnisha 2:d18857b99d3c 4 //
avnisha 2:d18857b99d3c 5 // ignore interrupt version till we discuss that topic
avnisha 2:d18857b99d3c 6 //
avnisha 2:d18857b99d3c 7
avnisha 2:d18857b99d3c 8 #ifdef INTERRUPT
avnisha 1:102ef7d39407 9 InterruptIn fire(p14);
avnisha 1:102ef7d39407 10 DigitalOut led(LED1);
avnisha 1:102ef7d39407 11 DigitalOut flash(LED4);
avnisha 1:102ef7d39407 12
avnisha 1:102ef7d39407 13 void ISR1() {
avnisha 1:102ef7d39407 14 led = !led;
avnisha 1:102ef7d39407 15 }
avnisha 1:102ef7d39407 16
avnisha 1:102ef7d39407 17 int main()
avnisha 1:102ef7d39407 18 {
avnisha 1:102ef7d39407 19 fire.rise(&ISR1);
avnisha 1:102ef7d39407 20 fire.fall(&ISR1);
avnisha 1:102ef7d39407 21
avnisha 1:102ef7d39407 22 while (1) {
avnisha 1:102ef7d39407 23 flash = !flash;
avnisha 1:102ef7d39407 24 wait(0.25);
avnisha 1:102ef7d39407 25 }
avnisha 1:102ef7d39407 26 }
avnisha 1:102ef7d39407 27
avnisha 2:d18857b99d3c 28 #endif
avnisha 2:d18857b99d3c 29
chris 0:0e4db18afd77 30 #include "mbed.h"
Cabal51 3:22fdf3a4be19 31 #include "C12832_lcd.h"
Cabal51 3:22fdf3a4be19 32
Cabal51 3:22fdf3a4be19 33 C12832_LCD lcd;
chris 0:0e4db18afd77 34
chris 0:0e4db18afd77 35 BusIn joy(p15,p12,p13,p16);
avnisha 1:102ef7d39407 36 InterruptIn fire(p14);
chris 0:0e4db18afd77 37
chris 0:0e4db18afd77 38 BusOut leds(LED1,LED2,LED3,LED4);
chris 0:0e4db18afd77 39
chris 0:0e4db18afd77 40 int main()
chris 0:0e4db18afd77 41 {
chris 0:0e4db18afd77 42 while(1) {
chris 0:0e4db18afd77 43 if (fire) {
chris 0:0e4db18afd77 44 leds=0xf;
Cabal51 3:22fdf3a4be19 45 lcd.cls();
Cabal51 3:22fdf3a4be19 46 lcd.locate(0,0);
Cabal51 3:22fdf3a4be19 47 lcd.printf("\n\rFIRE = ON ");
Cabal51 3:22fdf3a4be19 48
chris 0:0e4db18afd77 49 } else {
chris 0:0e4db18afd77 50 leds=joy;
Cabal51 3:22fdf3a4be19 51
Cabal51 3:22fdf3a4be19 52 if(joy == 0x8){
Cabal51 3:22fdf3a4be19 53 lcd.cls();
Cabal51 3:22fdf3a4be19 54 lcd.locate(0,0);
Cabal51 3:22fdf3a4be19 55 lcd.printf("\n\rRIGHT = ON ");
Cabal51 3:22fdf3a4be19 56 }
Cabal51 3:22fdf3a4be19 57 else if(joy == 0x4){
Cabal51 3:22fdf3a4be19 58 lcd.cls();
Cabal51 3:22fdf3a4be19 59 lcd.locate(0,0);
Cabal51 3:22fdf3a4be19 60 lcd.printf("\n\rLEFT = ON ");
Cabal51 3:22fdf3a4be19 61 }
Cabal51 3:22fdf3a4be19 62 else if(joy == 0x2){
Cabal51 3:22fdf3a4be19 63 lcd.cls();
Cabal51 3:22fdf3a4be19 64 lcd.locate(0,0);
Cabal51 3:22fdf3a4be19 65 lcd.printf("\n\rDOWN = ON ");
Cabal51 3:22fdf3a4be19 66 }
Cabal51 3:22fdf3a4be19 67 else if(joy == 0x1){
Cabal51 3:22fdf3a4be19 68 lcd.cls();
Cabal51 3:22fdf3a4be19 69 lcd.locate(0,0);
Cabal51 3:22fdf3a4be19 70 lcd.printf("\n\rUP = ON ");
Cabal51 3:22fdf3a4be19 71 }
Cabal51 3:22fdf3a4be19 72 else if(joy == 0x0){
Cabal51 3:22fdf3a4be19 73 lcd.cls();
Cabal51 3:22fdf3a4be19 74 lcd.locate(0,0);
Cabal51 3:22fdf3a4be19 75 lcd.printf("\n\rNONE ");
Cabal51 3:22fdf3a4be19 76 }
chris 0:0e4db18afd77 77 }
chris 0:0e4db18afd77 78 wait(0.1);
chris 0:0e4db18afd77 79 }
chris 0:0e4db18afd77 80 }
avnisha 2:d18857b99d3c 81