Andy Pomfret / Mbed OS UoY-rgb-LED

Files at this revision

API Documentation at this revision

Comitter:
ajp109
Date:
Tue Sep 29 09:54:49 2020 +0000
Commit message:
Initial commit of actual project (forked from base)

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed-os.lib Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 0ca75f717c65 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Sep 29 09:54:49 2020 +0000
@@ -0,0 +1,24 @@
+#include "mbed.h"
+
+int main()
+{
+    float const pi = 3.14159265359;
+    
+    // Initialise the digital pins D3, D5 and D6 as PWM outputs
+    PwmOut red(D2);
+    PwmOut green(D3);
+    PwmOut blue(D4);
+
+    // Loop forever...
+    while (true) {
+        // Loop the 'angle' variable from 0 to 359
+        for (int angle = 0; angle < 360; angle++) {
+            // Set the intensities of the LEDs
+            red = 0.5+0.5*sin(angle*pi/180);
+            green = 0.5+0.5*sin((angle+120)*pi/180);
+            blue = 0.5+0.5*sin((angle+240)*pi/180);
+            // The angle will change by one degree every 20ms
+            thread_sleep_for(20);
+        }
+    }
+}
diff -r 000000000000 -r 0ca75f717c65 mbed-os.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-os.lib	Tue Sep 29 09:54:49 2020 +0000
@@ -0,0 +1,1 @@
+https://github.com/armmbed/mbed-os/#aa70f680bb5755e8fea3f93fc6e04d9b3de235bb