vjezba 4.2 VU metar

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
dariomatijevic
Date:
Thu Dec 03 17:56:58 2015 +0000
Commit message:
dario_matijevic4.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 8bf79f07c1ce main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Dec 03 17:56:58 2015 +0000
@@ -0,0 +1,47 @@
+//Reads input through the ADC, and transfers to PC terminal
+ #include "mbed.h"
+  Serial pc(USBTX, USBRX);
+  AnalogIn Ain(p20);
+  DigitalOut myled1(LED1);  
+  DigitalOut myled2(LED2);  
+  DigitalOut myled3(LED3);  
+  DigitalOut myled4(LED4);  
+  float x; 
+  
+  int main() { 
+   while (1) { 
+   x=Ain; 
+    wait (0.5); 
+    if (x<=0.2){
+        myled1=0;
+        myled2=0;
+        myled3=0;
+        myled4=0;
+        }
+     if (x>0.2&x<=0.4){
+        myled1=1;
+        myled2=0;
+        myled3=0;
+        myled4=0;
+        }
+     if (x>0.4&x<=0.6){
+        myled1=1;
+        myled2=1;
+        myled3=0;
+        myled4=0;
+        }
+     if (x>0.6&x<=0.8){
+        myled1=1;
+        myled2=1;
+        myled3=1;
+        myled4=0;
+        }
+      if (x>0.8&x<=1.0){
+        myled1=1;
+        myled2=1;
+        myled3=1;
+        myled4=1;
+        }
+    } 
+    }
+ 
\ No newline at end of file
diff -r 000000000000 -r 8bf79f07c1ce mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu Dec 03 17:56:58 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/165afa46840b
\ No newline at end of file