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:0c2f82ec4865, 2013-07-04 (annotated)
- Committer:
 - ogata_lab
 - Date:
 - Thu Jul 04 03:25:30 2013 +0000
 - Revision:
 - 0:0c2f82ec4865
 
First Commit;
Who changed what in which revision?
| User | Revision | Line number | New contents of line | 
|---|---|---|---|
| ogata_lab | 0:0c2f82ec4865 | 1 | |
| ogata_lab | 0:0c2f82ec4865 | 2 | #include "mbed.h" | 
| ogata_lab | 0:0c2f82ec4865 | 3 | #include "Serial.h" | 
| ogata_lab | 0:0c2f82ec4865 | 4 | |
| ogata_lab | 0:0c2f82ec4865 | 5 | DigitalIn sw01(p20); | 
| ogata_lab | 0:0c2f82ec4865 | 6 | Serial usbSerial(USBTX, USBRX); | 
| ogata_lab | 0:0c2f82ec4865 | 7 | |
| ogata_lab | 0:0c2f82ec4865 | 8 | bool old_sw = false; | 
| ogata_lab | 0:0c2f82ec4865 | 9 | |
| ogata_lab | 0:0c2f82ec4865 | 10 | int main() { | 
| ogata_lab | 0:0c2f82ec4865 | 11 | |
| ogata_lab | 0:0c2f82ec4865 | 12 | sw01.mode(PullUp); | 
| ogata_lab | 0:0c2f82ec4865 | 13 | usbSerial.printf("Hello World!"); | 
| ogata_lab | 0:0c2f82ec4865 | 14 | int i = 0; | 
| ogata_lab | 0:0c2f82ec4865 | 15 | while(1) { | 
| ogata_lab | 0:0c2f82ec4865 | 16 | bool new_sw = sw01; | 
| ogata_lab | 0:0c2f82ec4865 | 17 | if(new_sw && !old_sw) { | 
| ogata_lab | 0:0c2f82ec4865 | 18 | i++; | 
| ogata_lab | 0:0c2f82ec4865 | 19 | } | 
| ogata_lab | 0:0c2f82ec4865 | 20 | usbSerial.printf("Counter = %d¥r¥n", i); | 
| ogata_lab | 0:0c2f82ec4865 | 21 | old_sw = new_sw; | 
| ogata_lab | 0:0c2f82ec4865 | 22 | |
| ogata_lab | 0:0c2f82ec4865 | 23 | } | 
| ogata_lab | 0:0c2f82ec4865 | 24 | } |