Dependencies:   mbed

Revision:
0:93eba49d1dc1
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Mar 26 10:21:16 2021 +0000
@@ -0,0 +1,37 @@
+//Write a program use pot values as color mixer on 2 channels of the RGB LED.
+
+#include "mbed.h"
+// setup analog inputs (pots) and digital outputs. 
+// digital outputs are only required to turn the RGB LED fully off on ititialising.
+DigitalOut R(p23); //Red pin of RGB LED
+DigitalOut G(p24); //Green pin of RGB LED
+DigitalOut B(p25); //Blue pin of RGB LED
+
+// declare PwmOut on red(p23) & blue(p25) of RGB.
+PwmOut g(p24);
+PwmOut r(p23);      
+               
+
+int main() {           
+
+R = G = B = 1; // init RGB led to off (all 1)   
+
+while(1)
+
+{       
+AnalogIn pot1(p19);// input from pot 1
+AnalogIn pot2(p20);// input from pot 2 
+    printf("pot value 1 = %f \n\r", pot1);
+//    g.period(4.0f);
+    g.write (1 /pot1);
+    printf("pot value 2 = %f \n\r", pot2);
+    r.write (1 /pot2);
+    wait (0.1);
+
+
+
+
+
+}
+
+}