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.
Fork of Task136 by
main.cpp@2:12fb933ccc6d, 2019-09-11 (annotated)
- Committer:
- noutram
- Date:
- Wed Sep 11 13:46:00 2019 +0000
- Revision:
- 2:12fb933ccc6d
- Parent:
- 0:6637f9cf2dc0
- Child:
- 3:c28e88869b5a
2019
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
noutram | 0:6637f9cf2dc0 | 1 | #include "mbed.h" |
noutram | 0:6637f9cf2dc0 | 2 | |
noutram | 2:12fb933ccc6d | 3 | Serial pc(SERIAL_TX, SERIAL_RX); |
noutram | 0:6637f9cf2dc0 | 4 | |
noutram | 2:12fb933ccc6d | 5 | DigitalOut greenLed(LED1,0); |
noutram | 2:12fb933ccc6d | 6 | DigitalOut blueLed(LED2,0); |
noutram | 2:12fb933ccc6d | 7 | DigitalOut redLed(LED3,0); |
noutram | 0:6637f9cf2dc0 | 8 | |
noutram | 0:6637f9cf2dc0 | 9 | int main() { |
noutram | 2:12fb933ccc6d | 10 | char nameString[30]; |
noutram | 2:12fb933ccc6d | 11 | int age; |
noutram | 0:6637f9cf2dc0 | 12 | |
noutram | 2:12fb933ccc6d | 13 | pc.printf("Enter your first name, then a space, then your age\n\r"); |
noutram | 2:12fb933ccc6d | 14 | pc.scanf("%s %d", nameString, &age); |
noutram | 2:12fb933ccc6d | 15 | pc.printf("Hello %s\n\r", nameString); |
noutram | 2:12fb933ccc6d | 16 | pc.printf("You are %d years old\n\r", age); |
noutram | 0:6637f9cf2dc0 | 17 | |
noutram | 2:12fb933ccc6d | 18 | //Loop forever |
noutram | 2:12fb933ccc6d | 19 | redLed = 1; |
noutram | 2:12fb933ccc6d | 20 | blueLed = 1; |
noutram | 2:12fb933ccc6d | 21 | greenLed = 1; |
noutram | 2:12fb933ccc6d | 22 | while(1); |
noutram | 0:6637f9cf2dc0 | 23 | } |
noutram | 2:12fb933ccc6d | 24 |