Vježba 2

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
cvitas
Date:
Tue Nov 19 18:47:21 2013 +0000
Commit message:
Vje?ba 2

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 02f125c03944 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Nov 19 18:47:21 2013 +0000
@@ -0,0 +1,41 @@
+#include "mbed.h"
+
+DigitalOut myled(LED1);
+AnalogIn Ain(p20);  //defines analog input on Pin 20
+
+BusOut Seg1 (p5,p6,p7,p8,p9,p10,p11,p12); // ABCDEFGDp, p5 je LSB
+
+char SegConvert(char SegValue) {  // function "SegConvert"
+    char SegByte=0x00;
+    switch (SegValue) {                    // DpGFEDCBA
+        case 0: SegByte = 0xC0; break;      // 00111111
+        case 1: SegByte = 0xF9; break;      // 00000110
+        case 2: SegByte = 0xA4; break;      // 01011011
+        case 3: SegByte = 0xB0; break;      // 01001111
+        case 4: SegByte = 0x99; break;      // 01100110
+        case 5: SegByte = 0x92; break;      // 01101101
+        case 6: SegByte = 0x82; break;      // 01111101
+        case 7: SegByte = 0xF8; break;      // 00000111
+        case 8: SegByte = 0x80; break;      // 01111111
+        case 9: SegByte = 0x90; break;      // 01101111
+    }
+    return SegByte;
+ }
+ char prikaz;
+ float Aout;
+ 
+int main() {
+    while(1) {
+    for (char i=0; i>9;i++){
+         prikaz = SegConvert(i);
+         Seg1= prikaz;
+         wait(1.5);
+         }
+    Aout=Ain;     //transfer analog in value to analog out
+    Aout = Aout * 10.0;
+    char ch = (char)Aout;
+    Seg1= SegConvert(ch);
+    wait(0.5);
+    
+    }
+}
diff -r 000000000000 -r 02f125c03944 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Tue Nov 19 18:47:21 2013 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/a9913a65894f
\ No newline at end of file