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.
main.cpp@0:ec68cfbf0495, 2016-08-15 (annotated)
- Committer:
- GregC
- Date:
- Mon Aug 15 18:15:42 2016 +0000
- Revision:
- 0:ec68cfbf0495
Serial and RGB LED program example for Hexiwear
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| GregC | 0:ec68cfbf0495 | 1 | #include "mbed.h" |
| GregC | 0:ec68cfbf0495 | 2 | #include "rtos.h" |
| GregC | 0:ec68cfbf0495 | 3 | |
| GregC | 0:ec68cfbf0495 | 4 | DigitalOut led_red(PTC8); |
| GregC | 0:ec68cfbf0495 | 5 | DigitalOut led_green(PTD0); |
| GregC | 0:ec68cfbf0495 | 6 | DigitalOut led_blue(PTC9); |
| GregC | 0:ec68cfbf0495 | 7 | Serial pc(USBTX, USBRX); |
| GregC | 0:ec68cfbf0495 | 8 | |
| GregC | 0:ec68cfbf0495 | 9 | int main() |
| GregC | 0:ec68cfbf0495 | 10 | { |
| GregC | 0:ec68cfbf0495 | 11 | pc.printf("Tell me the RGB LED Color\r\n"); |
| GregC | 0:ec68cfbf0495 | 12 | |
| GregC | 0:ec68cfbf0495 | 13 | while (true) { |
| GregC | 0:ec68cfbf0495 | 14 | pc.printf("Red\r\n"); // print the value of variable i |
| GregC | 0:ec68cfbf0495 | 15 | led_red=0; |
| GregC | 0:ec68cfbf0495 | 16 | led_green=1; |
| GregC | 0:ec68cfbf0495 | 17 | led_blue=1; |
| GregC | 0:ec68cfbf0495 | 18 | Thread::wait(1000); // wait a small period of time |
| GregC | 0:ec68cfbf0495 | 19 | pc.printf("Green\r\n"); // print the value of variable i |
| GregC | 0:ec68cfbf0495 | 20 | led_red=1; |
| GregC | 0:ec68cfbf0495 | 21 | led_green=0; |
| GregC | 0:ec68cfbf0495 | 22 | led_blue=1; |
| GregC | 0:ec68cfbf0495 | 23 | Thread::wait(1000); // wait a small period of time |
| GregC | 0:ec68cfbf0495 | 24 | pc.printf("Blue\r\n"); // print the value of variable i |
| GregC | 0:ec68cfbf0495 | 25 | led_red=1; |
| GregC | 0:ec68cfbf0495 | 26 | led_green=1; |
| GregC | 0:ec68cfbf0495 | 27 | led_blue=0; |
| GregC | 0:ec68cfbf0495 | 28 | Thread::wait(1000); // wait a small period of time |
| GregC | 0:ec68cfbf0495 | 29 | |
| GregC | 0:ec68cfbf0495 | 30 | } |
| GregC | 0:ec68cfbf0495 | 31 | } |
| GregC | 0:ec68cfbf0495 | 32 |