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:459c997f4e02, 2016-09-04 (annotated)
- Committer:
- yu10078999
- Date:
- Sun Sep 04 03:12:52 2016 +0000
- Revision:
- 0:459c997f4e02
- Child:
- 1:6e1ddfeea3c6
0
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| yu10078999 | 0:459c997f4e02 | 1 | #include "mbed.h" |
| yu10078999 | 0:459c997f4e02 | 2 | |
| yu10078999 | 0:459c997f4e02 | 3 | Serial esp8266(D6, D7);//tx, rx |
| yu10078999 | 0:459c997f4e02 | 4 | DigitalOut led(D2); |
| yu10078999 | 0:459c997f4e02 | 5 | |
| yu10078999 | 0:459c997f4e02 | 6 | int main() { |
| yu10078999 | 0:459c997f4e02 | 7 | while(1){ |
| yu10078999 | 0:459c997f4e02 | 8 | if (esp8266.readable()){ |
| yu10078999 | 0:459c997f4e02 | 9 | char val = esp8266.getc(); |
| yu10078999 | 0:459c997f4e02 | 10 | switch (val){ |
| yu10078999 | 0:459c997f4e02 | 11 | case 'a': |
| yu10078999 | 0:459c997f4e02 | 12 | led = 1; |
| yu10078999 | 0:459c997f4e02 | 13 | val=led.read(); |
| yu10078999 | 0:459c997f4e02 | 14 | esp8266.putc(led); |
| yu10078999 | 0:459c997f4e02 | 15 | break; |
| yu10078999 | 0:459c997f4e02 | 16 | case 'b': |
| yu10078999 | 0:459c997f4e02 | 17 | led = 0; |
| yu10078999 | 0:459c997f4e02 | 18 | val=led.read(); |
| yu10078999 | 0:459c997f4e02 | 19 | esp8266.putc(led); |
| yu10078999 | 0:459c997f4e02 | 20 | break; |
| yu10078999 | 0:459c997f4e02 | 21 | } |
| yu10078999 | 0:459c997f4e02 | 22 | } |
| yu10078999 | 0:459c997f4e02 | 23 | } |
| yu10078999 | 0:459c997f4e02 | 24 | } |
| yu10078999 | 0:459c997f4e02 | 25 |