Lab 4ES_ColourMixer John Curran T00214119

Dependencies:   mbed

Revision:
0:fb5ea244d4f6
Child:
1:03835eef0976
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sat Apr 17 09:26:21 2021 +0000
@@ -0,0 +1,58 @@
+// Lab 4 Colour Mixer
+// Control colours coming on using pot 1 and print values to tera term
+// John Curran T00214119
+#include "mbed.h"
+Serial pc(USBTX,USBRX);// serial communications
+DigitalOut redled(p23);// built in red led
+DigitalOut greenled(p24);// built in green led
+DigitalOut blueled(p25);// built in blue led
+AnalogIn Ain (p19); // Pot 1 control lights
+float ADCdata; // Reserve a space in memory
+
+int main ()
+{
+    while (1) {
+        ADCdata=Ain;//read pin 19
+
+        if(ADCdata>0.0 && ADCdata <= 0.2) {
+            pc.printf ( " ADCdata >0.0-<=0.2");
+            redled = 1;
+            greenled=1;
+            blueled= 1;
+            wait=(0.5);
+         
+        }
+        if(ADCdata>0.2 && ADCdata <= 0.4) {
+            pc.printf ( " ADCdata >0.2-<=0.4");
+            redled = 0;
+            greenled=1;
+            blueled= 1;
+            wait=(0.5);
+            
+        }
+        if(ADCdata>0.4 && ADCdata <= 0.8) {
+            pc.printf ( " ADCdata >0.4-<=0.8");
+            redled = 1;
+            greenled=0;
+            blueled= 1;
+            wait=(0.5);
+            
+        }
+        if(ADCdata>0.8 && ADCdata <= 0.9) {
+            pc.printf ( " ADCdata >0.8-<=0.9");
+            redled = 1;
+            greenled=1;
+            blueled= 0;
+            wait=(0.5);
+            
+        }
+        if(ADCdata>0.9 && ADCdata <= 1.0) {
+            pc.printf ( " ADCdata >0.9-<=1.0");
+            redled = 0;
+            greenled=0;
+            blueled= 1;
+            wait=(0.5);
+            
+        }
+        }
+        }
\ No newline at end of file