Very simple library for controll a 7 segment display.
Dependents: Demo_Led7seg TP1_EJER02_FERNANDEZ_CLERICI TP1_EJER3 Ejercicio3JalleVentiades ... more
Diff: main.cpp
- Revision:
- 0:ccabe7ff24e8
diff -r 000000000000 -r ccabe7ff24e8 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Fri Apr 22 22:30:33 2011 +0000 @@ -0,0 +1,39 @@ +#include "mbed.h" +#include "Multi7Seg.h" +//##### A simple Clock ##### +// Created by Michele Trombetta +// Copyright 2010 5OFT. All rights reserved. + +Ticker ticker_sec; +Multi7Seg minutes(p21, p22, p23, p24, p25, p26, p27, p20, p19, led_ANODE); +Multi7Seg hours(p21, p22, p23, p24, p25, p26, p27, p18, p17, led_ANODE); +DigitalOut seconds(p16); + +unsigned int cnt_h = 0, cnt_m = 0, cnt_s = 0; + +void inc_num() { + cnt_s++; + seconds = !seconds; + if (cnt_s == 60) { + cnt_s = 0; + cnt_m++; + } + if (cnt_m == 60) { + cnt_m = 0; + cnt_h++; + } + if (cnt_h == 24) cnt_h = 0; +} + +int main() { + + ticker_sec.attach(&inc_num, 1); + seconds = 0; + hours.setformat(format_DEC); + minutes.setformat(format_DEC); + + while (1) { + hours.write(cnt_h); + minutes.write(cnt_m); + } +} \ No newline at end of file