Orignal AVR Tiny USI Based I2C slave Charlieplexing 7SEG Test Program.

Dependencies:   My7SEG mbed

Committer:
bant62
Date:
Thu Dec 12 01:52:00 2013 +0000
Revision:
0:f3babdc5d382
Orignal AVR Tiny USI Based I2C slave Charlieplexing 7SEG LED Test Program.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bant62 0:f3babdc5d382 1 #include "mbed.h"
bant62 0:f3babdc5d382 2 #include "My7SEG.h"
bant62 0:f3babdc5d382 3
bant62 0:f3babdc5d382 4 I2C i2c(dp5,dp27); // sda, scl
bant62 0:f3babdc5d382 5 My7SEG _7seg(&i2c);
bant62 0:f3babdc5d382 6 DigitalOut led1(LED1);
bant62 0:f3babdc5d382 7 DigitalOut led2(LED2);
bant62 0:f3babdc5d382 8
bant62 0:f3babdc5d382 9 int main()
bant62 0:f3babdc5d382 10 {
bant62 0:f3babdc5d382 11 int hour,min,sec;
bant62 0:f3babdc5d382 12 char buf[9];
bant62 0:f3babdc5d382 13
bant62 0:f3babdc5d382 14 hour = 0;
bant62 0:f3babdc5d382 15 min = 0;
bant62 0:f3babdc5d382 16 sec = 0;
bant62 0:f3babdc5d382 17 led1 = 1;
bant62 0:f3babdc5d382 18 led2 = 0;
bant62 0:f3babdc5d382 19 while(1) {
bant62 0:f3babdc5d382 20 sprintf(buf,"%02d.%02d.%02d",hour,min,sec);
bant62 0:f3babdc5d382 21 _7seg.clear();
bant62 0:f3babdc5d382 22 _7seg.printStr(buf);
bant62 0:f3babdc5d382 23 led1 = !led1;
bant62 0:f3babdc5d382 24 led2 = !led2;
bant62 0:f3babdc5d382 25
bant62 0:f3babdc5d382 26 sec++;
bant62 0:f3babdc5d382 27 if (sec > 59) {
bant62 0:f3babdc5d382 28 sec = 0;
bant62 0:f3babdc5d382 29 min++;
bant62 0:f3babdc5d382 30 }
bant62 0:f3babdc5d382 31
bant62 0:f3babdc5d382 32 if (min > 59) {
bant62 0:f3babdc5d382 33 min = 0;
bant62 0:f3babdc5d382 34 hour++;
bant62 0:f3babdc5d382 35 }
bant62 0:f3babdc5d382 36
bant62 0:f3babdc5d382 37 if (hour > 23) {
bant62 0:f3babdc5d382 38 hour = 0;
bant62 0:f3babdc5d382 39 }
bant62 0:f3babdc5d382 40
bant62 0:f3babdc5d382 41 wait(1);
bant62 0:f3babdc5d382 42 }
bant62 0:f3babdc5d382 43 }