Haris Imamovic Almir Hamza

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
2016US_HarisImamovic
Date:
Fri Mar 25 17:45:11 2016 +0000
Commit message:
LV04_Grupa3_Tim3

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 10c827d52b6d main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Mar 25 17:45:11 2016 +0000
@@ -0,0 +1,25 @@
+#include "mbed.h"
+#define dp23 P0_0
+
+DigitalOut enable(dp14);
+BusOut lights(dp23, dp24, dp25, dp26, dp27, dp5, dp6, dp28);
+AnalogIn input(dp9);
+
+int main() {
+    
+    const float period = 0.1, step = 0.03889, epsilon = 0.00001;
+    char positions[9] = { 0, 1, 3, 7, 15, 31, 63, 127, 255 };
+    float data = 0;
+    enable = 0;
+    lights = 0;
+    
+    while(1) {
+        wait(period);
+        data = input - 0.65f;
+        
+        for(int i = 0; i < 9; i++) 
+            if( (data + epsilon > step * i) )
+                lights = positions[i];
+        
+    }
+}
diff -r 000000000000 -r 10c827d52b6d mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Fri Mar 25 17:45:11 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/c0f6e94411f5
\ No newline at end of file