4-2: LED VU metar

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
miljkovic
Date:
Thu Dec 03 17:59:28 2015 +0000
Commit message:
Vjezba 4-2: LED VU metar

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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Dec 03 17:59:28 2015 +0000
@@ -0,0 +1,61 @@
+#include "mbed.h"
+Serial pc(USBTX, USBRX);
+AnalogIn Ain(p20);
+
+DigitalOut led1(LED1);
+DigitalOut led2(LED2);
+DigitalOut led3(LED3);
+DigitalOut led4(LED4);
+
+int main() {
+ float ADCdata;
+ 
+while (1) {
+ADCdata=Ain;
+pc.printf("%f \n\r",ADCdata);
+ 
+ 
+        if(ADCdata<0.2)
+        {
+           myled1=0; 
+           myled2=0; 
+           myled3=0; 
+           myled4=0; 
+           
+        }
+        if((ADCdata>0.2)&&(ADCdata<0.4))
+        {
+           myled1=1; 
+           myled2=0; 
+           myled3=0; 
+           myled4=0; 
+           
+        }
+         if((ADCdata>0.4)&&(ADCdata<0.6))
+        {
+           myled1=1; 
+           myled2=1; 
+           myled3=0; 
+           myled4=0; 
+           
+        }
+         if((ADCdata>0.6)&&(ADCdata<0.8))
+        {
+           myled1=1; 
+           myled2=1; 
+           myled3=1; 
+           myled4=0; 
+           
+        }
+        if((ADCdata>0.8)&&(ADCdata<=1))
+         
+        {
+           myled1=1; 
+           myled2=1; 
+           myled3=1; 
+           myled4=1; 
+           
+        }
+   
+}
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu Dec 03 17:59:28 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/165afa46840b
\ No newline at end of file