Binary clock ; just set the RTC ( you can use http://mbed.org/users/roen/notebook/real-time/ ); format: hours, tens of minutes, minute units ; it uses pwm for leds in order to see leds position if not all of them are on

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
iaghici
Date:
Sun Dec 12 20:59:37 2010 +0000
Commit message:

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 0a4fa6c1adcd main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sun Dec 12 20:59:37 2010 +0000
@@ -0,0 +1,59 @@
+#include "mbed.h"
+#include <stdio.h>
+
+PwmOut led1(LED4);
+PwmOut led2(LED3);
+PwmOut led3(LED2);
+PwmOut led4(LED1);
+
+void ledoff(void)
+ { wait(0.6); led4=0.0; led3=0.0; led2=0.0; led1=0.0; wait(0.2); }
+
+void ledon(void)
+ { led4=0.05; led3=0.05; led2=0.05; led1=0.05; }
+ 
+int main()
+{
+ float minf;
+ int ora,min;
+ char buffer[5];
+while (1)
+ {
+   time_t seconds = time(NULL);
+   strftime(buffer, 5, "%I %M", localtime(&seconds));
+   sscanf (buffer,"%d %d",&ora, &min);
+
+   ledon();
+   if (ora>=8) { led4=0.9 ; ora=ora-8; }
+   if (ora>=4) { led3=0.9 ; ora=ora-4; }
+   if (ora>=2) { led2=0.9 ; ora=ora-4; }
+   if (ora>=1) { led1=0.9 ; ora=ora-1; }
+   
+   ledoff();
+   ledon();
+            
+   if ((min>=10) & (min<20)) { led1=0.9; }
+   if ((min>=20) & (min<30)) { led2=0.9; }
+   if ((min>=30) & (min<40)) { led1=0.9 ; led2=0.9; }    
+   if ((min>=40) & (min<50)) { led3=0.9; }
+   if ((min>=50) & (min<60)) { led3=0.9; led1=0.9; }
+    
+   ledoff();
+   ledon();
+            
+   minf=fmod(min,10.0);
+   if (minf==1) led1=0.9;
+   if (minf==2) led2=0.9;
+   if (minf==3) { led1=0.9; led2=0.9; }
+   if (minf==4) led3=0.9;
+   if (minf==5) { led1=0.9; led3=0.9; }
+   if (minf==6) { led2=0.9; led3=0.9; }
+   if (minf==7) { led1=0.9; led2=0.9; led3=0.9; }
+   if (minf==8) led4=0.9;
+   if (minf==9) { led1=0.9; led4=0.9; }
+
+   ledoff();
+   wait(0.3);
+
+ }
+}
\ No newline at end of file
diff -r 000000000000 -r 0a4fa6c1adcd mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sun Dec 12 20:59:37 2010 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/e2ac27c8e93e