Eleanor Hulm
/
EMB_LAB3
Controlling onboard RGB LED with Pulse-Width Modulation
EMB_Lab3_RGB.cpp
- Committer:
- hulmpants
- Date:
- 2019-08-17
- Revision:
- 1:31823a0dc268
File content as of revision 1:31823a0dc268:
// 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); } }