![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Simple example of using a rotary encoder to drive an RGB LED. At first, you can control the brightness of the red LED. Push the encoder shaft in and you can then control green. Push again to control blue. Then it repeats.
Dependencies: mRotaryEncoder mbed
Revision 1:126964580159, committed 2016-12-29
- Comitter:
- wd5gnr
- Date:
- Thu Dec 29 19:49:50 2016 +0000
- Parent:
- 0:3e6a4dfbcb88
- Commit message:
- Made PWM output faster
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 3e6a4dfbcb88 -r 126964580159 main.cpp --- a/main.cpp Thu Dec 29 06:01:32 2016 +0000 +++ b/main.cpp Thu Dec 29 19:49:50 2016 +0000 @@ -66,5 +66,9 @@ enc.attachROTCW(cw); enc.attachROTCCW(ccw); enc.attachSW(btn); + // set fast period + redled.period(0.01); + greenled.period(0.01); + blueled.period(0.01); while (true); // nothing else to do but wait } \ No newline at end of file