Embedded IO Homework 1 binary up/down counter

Dependencies:   C12832_lcd mbed

Committer:
Cabal51
Date:
Fri Oct 18 02:45:20 2013 +0000
Revision:
0:82a38170d1ba
Embedded IO Homework 1 binary up/down counter

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Cabal51 0:82a38170d1ba 1 /*
Cabal51 0:82a38170d1ba 2 Author: Brian Tilton
Cabal51 0:82a38170d1ba 3
Cabal51 0:82a38170d1ba 4 */
Cabal51 0:82a38170d1ba 5
Cabal51 0:82a38170d1ba 6 #include "mbed.h"
Cabal51 0:82a38170d1ba 7 #include "C12832_lcd.h"
Cabal51 0:82a38170d1ba 8
Cabal51 0:82a38170d1ba 9 BusOut Bits(LED1,LED2,LED3,LED4);
Cabal51 0:82a38170d1ba 10 C12832_LCD lcd;
Cabal51 0:82a38170d1ba 11
Cabal51 0:82a38170d1ba 12 int binval = 0x00;
Cabal51 0:82a38170d1ba 13 bool flipS = false;
Cabal51 0:82a38170d1ba 14 int clrScrn = 0;
Cabal51 0:82a38170d1ba 15 int main() {
Cabal51 0:82a38170d1ba 16 while(1){
Cabal51 0:82a38170d1ba 17 Bits = binval;
Cabal51 0:82a38170d1ba 18 lcd.cls();
Cabal51 0:82a38170d1ba 19 lcd.locate(0,0);
Cabal51 0:82a38170d1ba 20 lcd.printf("%X\r",binval);
Cabal51 0:82a38170d1ba 21
Cabal51 0:82a38170d1ba 22 if(binval == 0x0f)
Cabal51 0:82a38170d1ba 23 flipS = true;
Cabal51 0:82a38170d1ba 24 if(flipS == false)
Cabal51 0:82a38170d1ba 25 binval ++;
Cabal51 0:82a38170d1ba 26 if(binval == 0x00){
Cabal51 0:82a38170d1ba 27 flipS = false;
Cabal51 0:82a38170d1ba 28 binval++;
Cabal51 0:82a38170d1ba 29 }
Cabal51 0:82a38170d1ba 30 if(flipS == true)
Cabal51 0:82a38170d1ba 31 binval--;
Cabal51 0:82a38170d1ba 32
Cabal51 0:82a38170d1ba 33 wait(1);
Cabal51 0:82a38170d1ba 34 }
Cabal51 0:82a38170d1ba 35 }