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:6e5c26cd4410, 2020-11-25 (annotated)
- Committer:
- aoi_tech
- Date:
- Wed Nov 25 01:28:30 2020 +0000
- Revision:
- 0:6e5c26cd4410
Switching lighting
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| aoi_tech | 0:6e5c26cd4410 | 1 | #include "mbed.h" |
| aoi_tech | 0:6e5c26cd4410 | 2 | |
| aoi_tech | 0:6e5c26cd4410 | 3 | Serial pc(USBTX,USBRX); |
| aoi_tech | 0:6e5c26cd4410 | 4 | DigitalOut led(PB_3); |
| aoi_tech | 0:6e5c26cd4410 | 5 | |
| aoi_tech | 0:6e5c26cd4410 | 6 | int main() |
| aoi_tech | 0:6e5c26cd4410 | 7 | { |
| aoi_tech | 0:6e5c26cd4410 | 8 | pc.baud(9600); |
| aoi_tech | 0:6e5c26cd4410 | 9 | int val = 0; |
| aoi_tech | 0:6e5c26cd4410 | 10 | int onoff = 0; |
| aoi_tech | 0:6e5c26cd4410 | 11 | while(true){ |
| aoi_tech | 0:6e5c26cd4410 | 12 | val = pc.readable(); |
| aoi_tech | 0:6e5c26cd4410 | 13 | if(val == 1){ |
| aoi_tech | 0:6e5c26cd4410 | 14 | onoff = pc.getc(); |
| aoi_tech | 0:6e5c26cd4410 | 15 | if(onoff == 83 || onoff == 115){ |
| aoi_tech | 0:6e5c26cd4410 | 16 | led = 1; |
| aoi_tech | 0:6e5c26cd4410 | 17 | } |
| aoi_tech | 0:6e5c26cd4410 | 18 | else if(onoff == 69 || onoff == 101){ |
| aoi_tech | 0:6e5c26cd4410 | 19 | led = 0; |
| aoi_tech | 0:6e5c26cd4410 | 20 | } |
| aoi_tech | 0:6e5c26cd4410 | 21 | } |
| aoi_tech | 0:6e5c26cd4410 | 22 | } |
| aoi_tech | 0:6e5c26cd4410 | 23 | } |