Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Revision 0:657f19640bf8, committed 2015-12-16
- Comitter:
- co657_at435
- Date:
- Wed Dec 16 18:14:46 2015 +0000
- Commit message:
- initial xbeeLEDController;
Changed in this revision
control.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 |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/control.cpp Wed Dec 16 18:14:46 2015 +0000 @@ -0,0 +1,53 @@ +// Chinese knock off Philips hue + +#include "mbed.h" + +/* LEDs */ +DigitalOut red_led(D5); +DigitalOut blue_led(PTC12); +DigitalOut green_led(D9); + +Serial xbee(D1,D0); +Serial mac( USBTX , USBRX ); + +bool isLeader = false; +char group; + +void ChangeColour(char rgb) +{ + bool R = rgb & 0x4; + bool G = rgb & 0x2; + bool B = rgb & 0x1; + + mac.printf("Red: %d, Green: %d, Blue %d\n",R,G,B); + + red_led = !R; + green_led = !G; + blue_led = !B; +} + +void ListenXbee(void) +{ + //read Xbee if possible \ + while (xbee.readable()) + { + char message = xbee.getc(); + mac.printf("%d\n",(int)message); + ChangeColour(message); + } +} + +int main () { + mac.baud (38400); + mac.printf("We are reciving\n"); + for (;;) { + if (!isLeader) { + ListenXbee(); + } + wait_ms(100); + } +} + + + +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Wed Dec 16 18:14:46 2015 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/34e6b704fe68 \ No newline at end of file