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

Files at this revision

API Documentation at this revision

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
--- 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