
Lab that has to do with basic IO on mbed.
Dependencies: DebounceIn mbed PinDetect
Diff: GeorgesLab1/GeorgeMain.cpp
- Revision:
- 51:e12b3635afae
- Parent:
- 50:9201ce9854dc
--- a/GeorgesLab1/GeorgeMain.cpp Sun Jan 24 20:58:34 2016 +0000 +++ b/GeorgesLab1/GeorgeMain.cpp Sun Jan 24 16:32:04 2016 -0500 @@ -1,3 +1,4 @@ +/* #include "mbed.h" #include "DebounceIn.h" #include "PinDetect.h" @@ -9,8 +10,8 @@ PinDetect pb(p20); PinDetect assemblyPB(p28); DigitalOut myled1(LED1); -DigitalOut myled2(LED2); -DigitalOut myled3(LED3); +DigitalOut myled2(LED2); +DigitalOut myled3(LED3); DigitalOut myled4(LED4); DigitalOut assemblyLED(p30); PwmOut discrete_led(p21); @@ -74,23 +75,23 @@ int main() { - + pb.mode(PullUp); assemblyPB.mode(PullUp); - + float brightness = 0; - - + + if (pb) { spi.format(16,0); spi.frequency(1000000); latch=0; wait(2); while(1) { - + //Assembly green LED my_asm(!assemblyPB); - + //code for red led brightness = voltage_reg; myled1 = !pb; @@ -100,7 +101,7 @@ else{ discrete_led.write(0); } - + //code for multicolor led float heatmapColor = voltage_reg.read()*float(1000); if (heatmapColor < 0) {heatmapColor=0;} @@ -108,24 +109,24 @@ RGB_LED(RGB_val[0], RGB_val[1], RGB_val[2]); //wait(.2); } - + } else { int count = 0; // On reset, indicate a watchdog reset or a pushbutton reset on LED 4 or 3 if ((LPC_WDT->WDMOD >> 2) & 1) myled4 = 1; else myled3 = 1; - + // setup a 10 second timeout on watchdog timer hardware // needs to be longer than worst case main loop exection time - wdt.kick(10.0); - - // Main program loop - resets watchdog once each loop iteration + wdt.kick(10.0); + + // Main program loop - resets watchdog once each loop iteration // Would typically have a lot of code in loop with many calls while (1) { //Assembly Green LED my_asm(!assemblyPB); - + myled1 = 1; //Flash LEDs 1 & 2 to indicate normal loop activity wait(.05); myled1 = 0;