![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
demo that cycles the led strip with a fade and with no fade
Dependencies: mbed
Revision 0:b33f0064af58, committed 2017-05-12
- Comitter:
- MattShilling
- Date:
- Fri May 12 20:58:31 2017 +0000
- Commit message:
- publish strip_master_demo;
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
diff -r 000000000000 -r b33f0064af58 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Fri May 12 20:58:31 2017 +0000 @@ -0,0 +1,57 @@ +#include "mbed.h" + +Serial pc(USBTX, USBRX); // tx, rx + +PwmOut blue(D2); +PwmOut green(D3); +PwmOut red(D4); + +#define RED 0 +#define GREEN 2 +#define BLUE 1 + +volatile bool fade = false; + +volatile float amnt = 1; + +void handle_input(){ + + //if(pc.readable()){ + char input = pc.getc(); + + // on/off + if(input == '1'){ + pc.printf("On/Off 1 Sec Cycle!\n"); + fade = false; + } + + // fade + else if(input == '2'){ + pc.printf("Fade On/Off 1 sec cycle!\n"); + fade = true; + } + + +} + +int main() { + + // set the + blue.period_ms(10); + green.period_ms(10); + red.period_ms(10); + + while(1){ + + + if(pc.readable()){ + handle_input(); + + red = 1; + green.pulsewidth_us((int)(amnt*100)); + blue = 1; + + } + + } +}
diff -r 000000000000 -r b33f0064af58 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Fri May 12 20:58:31 2017 +0000 @@ -0,0 +1,1 @@ +https://mbed.org/users/mbed_official/code/mbed/builds/4eea097334d6 \ No newline at end of file