Laboratorijska vježba 4.2 Martin Braim

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
MBraim
Date:
Thu Dec 03 18:03:04 2015 +0000
Commit message:
Laboratorijska vje?ba 4.2; Martin Braim; 03.12.2015.

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 18:03:04 2015 +0000
@@ -0,0 +1,47 @@
+//Reads input through the ADC, and transfers to PC terminal
+#include "mbed.h"
+Serial pc(USBTX, USBRX);
+DigitalOut myled(LED1);
+DigitalOut myled1(LED2);
+DigitalOut myled2(LED3);
+DigitalOut myled3(LED4);
+AnalogIn Ain(p20);
+float ADCdata;
+int main() {
+pc.printf("ADC Data Values... \n\r");
+while (1) { 
+ADCdata=Ain;  
+if (ADCdata <= 0.2){ 
+    myled = 0;
+    myled1 = 0;
+    myled2 = 0;
+    myled3 = 0;
+    wait(0.1);}   
+else if ((ADCdata > 0.2) && (ADCdata <= 0.4)){
+        myled = 1;
+        myled1 = 0;
+        myled2 = 0;
+        myled3 = 0;
+        wait(0.1);}
+else if ((ADCdata > 0.4) && (ADCdata <= 0.6)){
+        myled = 1;
+        myled1 = 1;
+        myled2 = 0;
+        myled3 = 0;
+        wait(0.1);}       
+else if ((ADCdata > 0.6) && (ADCdata <= 0.8)){
+        myled = 1;
+        myled1 = 1;
+        myled2 = 1;
+        myled3 = 0;
+        wait(0.1);}       
+else if ((ADCdata > 0.8) && (ADCdata <= 1.0)){
+        myled = 1;
+        myled1 = 1;
+        myled2 = 1;
+        myled3 = 1;
+        wait(0.1);}
+pc.printf("%f \n\r",ADCdata);
+//wait (0.5); 
+}
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu Dec 03 18:03:04 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/165afa46840b
\ No newline at end of file