![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
Control an LED from a computer via the serial port
Dependencies: mbed
Revision 0:da809d54f2ce, committed 2014-06-01
- Comitter:
- ethanharstad
- Date:
- Sun Jun 01 03:41:48 2014 +0000
- Child:
- 1:c064570d8b35
- Commit message:
- Initial commit
Changed in this revision
PhysicalPixel.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/PhysicalPixel.cpp Sun Jun 01 03:41:48 2014 +0000 @@ -0,0 +1,27 @@ +#include "mbed.h" + +// Global variables +DigitalOut led(LED1); +Serial pc(USBTX, USBRX); + +// Function prototypes +void handleInput(char in); + +// Main function +int main() { + while(true) { + if(pc.readable()) { + char c = pc.getc(); + handleInput(c); + } + } +} + +// Input handler +void handleInput(char in) { + if(in == 'H') { + led = 1; + } else if(in == 'L') { + led = 0; + } +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Sun Jun 01 03:41:48 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/0b3ab51c8877 \ No newline at end of file