Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Revision 1:31823a0dc268, committed 2019-08-17
- Comitter:
- hulmpants
- Date:
- Sat Aug 17 09:43:21 2019 +0000
- Parent:
- 0:f86c572491c3
- Commit message:
- Embedded Systems Laboratory 3; Controlling RGB LED with Pulse-Width Modulation;
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/C12832_lcd.lib Sat Aug 17 09:43:21 2019 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/dreschpe/code/C12832_lcd/#8f86576007d6
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/EMB_Lab3_RGB.cpp Sat Aug 17 09:43:21 2019 +0000
@@ -0,0 +1,27 @@
+// IT Tralee Mechatronics: Embedded Systems LAB#3
+// Controlling RGB using PWM
+
+#include "mbed.h"
+#include "C12832_lcd.h"
+
+C12832_LCD lcd;
+PwmOut r (p23);
+PwmOut g (p24);
+PwmOut b (p25);
+AnalogIn pot1(p19); // pot 1 = red
+AnalogIn pot2(p20); // pot 2 = green
+DigitalIn center(p14); // joystick cent = blue
+
+int main() {
+ while(1) {
+ r = 1 - pot1; // range=0-1 / 1=max red / levels varied by changing pot
+ g = 1 - pot2;
+ b = 1 - center;
+ lcd.cls(); // clear LCD
+ lcd.locate(0,0); // location
+ lcd.printf("Fun RGB Rainbow Show :) \n \r");
+ lcd.locate(0,8);
+ lcd.printf("Pot 1 = %.2f", (float)pot1); // print pot value
+ lcd.locate(0,16);
+ lcd.printf("Pot 2 = %.2f", (float)pot2); }
+}
--- a/main.cpp Mon Oct 15 12:19:12 2012 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,19 +0,0 @@
-#include "mbed.h"
-
-PwmOut r (p23);
-PwmOut g (p24);
-PwmOut b (p25);
-
-int main()
-{
- r.period(0.001);
- while(1) {
- for(float i = 0.0; i < 1.0 ; i += 0.001) {
- float p = 3 * i;
- r = 1.0 - ((p < 1.0) ? 1.0 - p : (p > 2.0) ? p - 2.0 : 0.0);
- g = 1.0 - ((p < 1.0) ? p : (p > 2.0) ? 0.0 : 2.0 - p);
- b = 1.0 - ((p < 1.0) ? 0.0 : (p > 2.0) ? 3.0 - p : p - 1.0); ;
- wait (0.01);
- }
- }
-}
\ No newline at end of file