Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: main.cpp
- Revision:
- 0:c56e478174a2
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Thu Mar 20 19:21:10 2014 +0000
@@ -0,0 +1,120 @@
+#include "mbed.h"
+
+DigitalOut enable(dp14);
+BusOut displej(dp26, dp27, dp5, dp6, dp28, dp1, dp2);
+DigitalOut kolona[4] = {dp16, dp15, dp17, dp18};
+DigitalIn red[4] = {dp9, dp10, dp11, dp13};
+DigitalOut seg(dp25), seg1(dp23), seg2(dp24);
+
+int preset()
+{
+ for(int i=0; i<4; i++)
+ {
+ kolona[i] = 1;
+ for(int j=0; j<4; j++)
+ {
+ if(red[j]==1)
+ {
+ kolona[i]=0;
+ return 4*i+j;
+ }
+ }
+ kolona[i]=0;
+ }
+ return -1;
+}
+
+int cifra1=0, cifra2=0, cifra3=0;
+
+
+
+void ispisi(int x)
+{
+ if(cifra1!=0)
+ {
+ return;
+ }
+ int temp=cifra3;
+ cifra3=x;
+ cifra1=cifra2;
+ cifra2=temp;
+ for(;;)
+ {
+ displej = cifra3;
+ seg = 0;
+ wait(0.001);
+ seg = 1;
+ displej = cifra2;
+ seg2 = 0;
+ wait(0.001);
+ seg2=1;
+ displej=cifra1;
+ seg1 = 0;
+ wait(0.001);
+ seg1=1;
+ }
+}
+
+int main() {
+ enable=1;
+
+ while(1) {
+ if(preset()==0)
+ {
+ ispisi(121);
+ }
+ else if(preset()==1)
+ {
+ ispisi(36);
+ }
+
+ else if(preset()==2)
+ {
+ ispisi(48);
+ }
+
+ else if(preset()==4)
+ {
+ ispisi(25);
+ }
+
+ else if(preset()==5)
+ {
+ ispisi(18);
+ }
+
+ else if(preset()==6)
+ {
+ ispisi(2);
+ }
+
+ else if(preset()==8)
+ {
+ ispisi(120);
+ }
+
+ else if(preset()==9)
+ {
+ ispisi(0);
+ }
+
+ else if(preset()==10)
+ {
+ ispisi(16);
+ }
+
+ else if(preset()==13)
+ {
+ ispisi(64);
+ }
+
+ else if(preset()==11)
+ {
+ displej=64;
+ seg=0;
+ seg1=0;
+ seg2=0;
+ }
+ }
+}
+
\ No newline at end of file