Counts to 15 and back to 0 using the 4 LEDs
Dependencies: C12832_lcd LM75B mbed
Fork of app-board-LM75B by
Diff: main.cpp
- Revision:
- 4:18680ed950a8
- Parent:
- 3:4d612f16ad84
--- a/main.cpp Fri Oct 26 21:42:06 2012 +0000 +++ b/main.cpp Tue Apr 29 01:49:55 2014 +0000 @@ -1,18 +1,30 @@ #include "mbed.h" -#include "LM75B.h" -#include "C12832_lcd.h" -C12832_LCD lcd; -LM75B tmp(p28,p27); +DigitalOut blue3(LED1); +DigitalOut blue2(LED2); +DigitalOut blue1(LED3); +DigitalOut blue0(LED4); int main () { - + int numToDisplay = 0; + int highNum = 15; + + if(highNum > 15) { + error("Number too high to count to!"); + } while (1) { - lcd.cls(); - lcd.locate(0,3); - lcd.printf("%.2f\n",tmp.read()); - wait(1.0); + for (int i = 0; i < 2*highNum; i++) { + numToDisplay = i; + if (i > highNum) { + numToDisplay = 2*highNum - i; + } + + blue3 = (numToDisplay & 8); + blue2 = (numToDisplay & 4); + blue1 = (numToDisplay & 2); + blue0 = (numToDisplay & 1); + wait(1.0); + } } - }