Example program to cycle the RGB LED on the mbed application board through all colours
Dependencies: C12832_lcd LCD_fonts mbed
Fork of app-board-RGB by
Test Program to show the RGB Led on the mbed Lab Board
The color is changed by Pot 2, the value by Pot 1.
The program use a function to convert hue , saturation and value to RGB.
With this parameters you can change the color thru the rainbow. see http://en.wikipedia.org/wiki/HSL_and_HSV
Revision 3:139f52e5e15c, committed 2012-12-05
- Comitter:
- dreschpe
- Date:
- Wed Dec 05 08:08:41 2012 +0000
- Parent:
- 2:52c13333401e
- Commit message:
- The lcd lib don't claim the printf now, so we have to call LCD.printf
Changed in this revision
diff -r 52c13333401e -r 139f52e5e15c C12832_lcd.lib --- a/C12832_lcd.lib Sat Oct 20 09:14:13 2012 +0000 +++ b/C12832_lcd.lib Wed Dec 05 08:08:41 2012 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/dreschpe/code/C12832_lcd/#bdc53502af17 +http://mbed.org/users/dreschpe/code/C12832_lcd/#0f53e522a2bf
diff -r 52c13333401e -r 139f52e5e15c LCD_fonts.lib --- a/LCD_fonts.lib Sat Oct 20 09:14:13 2012 +0000 +++ b/LCD_fonts.lib Wed Dec 05 08:08:41 2012 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/dreschpe/code/LCD_fonts/#ac9b0945fdb1 +http://mbed.org/users/dreschpe/code/LCD_fonts/#d0b7d7bf1f56
diff -r 52c13333401e -r 139f52e5e15c main.cpp --- a/main.cpp Sat Oct 20 09:14:13 2012 +0000 +++ b/main.cpp Wed Dec 05 08:08:41 2012 +0000 @@ -11,19 +11,20 @@ #include "mbed.h" +#include "C12832_lcd.h" #include "Small_7.h" #include "Arial_9.h" -#include "stdio.h" -#include "C12832_lcd.h" +//#include "stdio.h" + + +// LCD object +C12832_LCD lcd; /* the led's are connected to vcc, so a PwmOut of 100% will shut off the led and 0% will let it shine ! */ PwmOut r (p23); PwmOut g (p24); PwmOut b (p25); -// LCD object -C12832_LCD LCD("LCD"); - AnalogIn Pot1(p19); AnalogIn Pot2(p20); @@ -92,30 +93,28 @@ float h; // hue float s,v; // saturation and value; unsigned short temp; - r.period(0.001); // set pwm period - LCD.claim(stdout); // send stdout to the LCD display - LCD.cls(); - LCD.locate(10,0); - LCD.set_font((unsigned char*) Arial_9); - printf("RGB Led Demo"); - LCD.copy_to_lcd(); - LCD.set_font((unsigned char*) Small_7); + lcd.cls(); + lcd.locate(10,0); + lcd.set_font((unsigned char*) Arial_9); + lcd.printf("RGB Led Demo"); + lcd.set_font((unsigned char*) Small_7); + + r.period(0.001); // set pwm period s = 1.0; for(;;){ // get Poti 1 for color temp = Pot1.read_u16(); temp = temp >> 6; // truncate to 10 Bit h = temp * 0.3515625; // scale to 0 - 360; - LCD.locate(0,13); - printf("Colour = %3.2f degree",h); + lcd.locate(0,13); + lcd.printf("Colour = %3.2f degree",h); // get Poti 2 fo value temp = Pot2.read_u16(); temp = temp >> 6; v = temp * 0.0009765624; // scale to 0 - 1; - LCD.locate(0,23); - printf("Val = %01.3f ",v); - LCD.copy_to_lcd(); + lcd.locate(0,23); + lcd.printf("Val = %01.3f ",v); hsv2rgb(h,s,v); wait_ms(500); }
diff -r 52c13333401e -r 139f52e5e15c mbed.bld --- a/mbed.bld Sat Oct 20 09:14:13 2012 +0000 +++ b/mbed.bld Wed Dec 05 08:08:41 2012 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/mbed_official/code/mbed/builds/cd19af002ccc \ No newline at end of file +http://mbed.org/users/mbed_official/code/mbed/builds/b60934f96c0c \ No newline at end of file