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
Diff: main.cpp
- Revision:
- 2:52c13333401e
- Parent:
- 1:670665e77763
- Child:
- 3:139f52e5e15c
--- a/main.cpp Sat Oct 20 00:21:54 2012 +0000 +++ b/main.cpp Sat Oct 20 09:14:13 2012 +0000 @@ -5,6 +5,8 @@ * the saturation is set to maximum * * Copyright (c) 2012 Peter Drescher - DC2PD + * This Demo run only on LPC1768 ! + * The LPC11U24 has different PWM pins ! */ @@ -89,7 +91,7 @@ { float h; // hue float s,v; // saturation and value; - float temp,temp2; + unsigned short temp; r.period(0.001); // set pwm period LCD.claim(stdout); // send stdout to the LCD display @@ -97,19 +99,20 @@ 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); s = 1.0; for(;;){ // get Poti 1 for color - temp = Pot1.read(); - temp2 = Pot1.read(); - h = (temp + temp2) * 180; + 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 ",h); + printf("Colour = %3.2f degree",h); // get Poti 2 fo value - temp = Pot2.read(); - temp2 = Pot2.read(); - v = (temp + temp2) / 2; + 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();