Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
BertieHarte
Date:
Fri Mar 26 10:21:16 2021 +0000
Commit message:
make public

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 93eba49d1dc1 main.cpp
--- /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);
+
+
+
+
+
+}
+
+}
diff -r 000000000000 -r 93eba49d1dc1 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Fri Mar 26 10:21:16 2021 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400
\ No newline at end of file