Lab1
Dependencies: mbed Joystick MPR121_Demo
Diff: main.cpp
- Revision:
- 1:a8881b932dd3
- Parent:
- 0:b6b25be5f240
--- a/main.cpp Tue Aug 30 21:22:13 2016 +0000 +++ b/main.cpp Fri Sep 02 17:20:11 2016 +0000 @@ -1,12 +1,33 @@ #include "mbed.h" -DigitalOut myled(LED1); +DigitalIn dip(p13); +DigitalIn PB1(p11); +DigitalIn PB2(p12); +PwmOut red_light(p21); +//PwmOut green_light(p22); +//PwmOut blue_light(p23); +//void RGB_light(int r, int g, int b) { +// red_light = r; +// green_light = g; +// blue_light = b; +//} int main() { + float brightness = 0.5; while(1) { - myled = 1; - wait(0.2); - myled = 0; - wait(0.2); + if(dip){ + red_light = 0.0; + } + else { + red_light = brightness; + } + if(!PB1 && brightness < 1) { + brightness = brightness + .1; + wait(.5); + } + if(!PB2 && brightness > 0) { + brightness = brightness - .1; + wait(.5); + } } -} +} \ No newline at end of file