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.
Dependencies: mbed
Fork of DigitalIn_HelloWorld_Mbed by
main.cpp@6:fa65447e171b, 2015-03-27 (annotated)
- Committer:
- mbedAustin
- Date:
- Fri Mar 27 21:01:15 2015 +0000
- Revision:
- 6:fa65447e171b
- Parent:
- 5:9b20ef58e04c
- Child:
- 7:315942f167d7
Updated program to reflect more of the API
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| mbedAustin | 5:9b20ef58e04c | 1 | /* mbed Example Program |
| mbedAustin | 5:9b20ef58e04c | 2 | * Copyright (c) 2006-2014 ARM Limited |
| mbedAustin | 5:9b20ef58e04c | 3 | * |
| mbedAustin | 5:9b20ef58e04c | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| mbedAustin | 5:9b20ef58e04c | 5 | * you may not use this file except in compliance with the License. |
| mbedAustin | 5:9b20ef58e04c | 6 | * You may obtain a copy of the License at |
| mbedAustin | 5:9b20ef58e04c | 7 | * |
| mbedAustin | 5:9b20ef58e04c | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| mbedAustin | 5:9b20ef58e04c | 9 | * |
| mbedAustin | 5:9b20ef58e04c | 10 | * Unless required by applicable law or agreed to in writing, software |
| mbedAustin | 5:9b20ef58e04c | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| mbedAustin | 5:9b20ef58e04c | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| mbedAustin | 5:9b20ef58e04c | 13 | * See the License for the specific language governing permissions and |
| mbedAustin | 5:9b20ef58e04c | 14 | * limitations under the License. |
| mbedAustin | 5:9b20ef58e04c | 15 | */ |
| mbed_official | 0:aaf5a9d465fd | 16 | #include "mbed.h" |
| mbedAustin | 6:fa65447e171b | 17 | |
| mbedAustin | 6:fa65447e171b | 18 | DigitalIn mypin(BUTTON1); |
| mbedAustin | 6:fa65447e171b | 19 | DigitalOut myled(LED1); |
| mbedAustin | 6:fa65447e171b | 20 | |
| mbedAustin | 6:fa65447e171b | 21 | int main() |
| mbedAustin | 6:fa65447e171b | 22 | { |
| mbedAustin | 6:fa65447e171b | 23 | // check mypin object is initialized and connected to a pin |
| mbedAustin | 6:fa65447e171b | 24 | int check = mypin.is_connected(); |
| mbedAustin | 6:fa65447e171b | 25 | if(check) { |
| mbedAustin | 6:fa65447e171b | 26 | printf("mypin is connected and initialized! \n\r"); |
| mbedAustin | 6:fa65447e171b | 27 | } |
| mbedAustin | 6:fa65447e171b | 28 | |
| mbedAustin | 6:fa65447e171b | 29 | // Set resistance on line |
| mbedAustin | 6:fa65447e171b | 30 | mypin.mode(PullNone); // valid modes are PullUp, PullDown, PullNone, OpenDrain |
| mbedAustin | 6:fa65447e171b | 31 | |
| mbedAustin | 6:fa65447e171b | 32 | // press the button and see the console / led change |
| mbed_official | 0:aaf5a9d465fd | 33 | while(1) { |
| mbedAustin | 6:fa65447e171b | 34 | printf("mypin has value : %d \n\r", mypin.read()); |
| mbedAustin | 6:fa65447e171b | 35 | myled = mypin; // toggle led based on value of button |
| mbed_official | 0:aaf5a9d465fd | 36 | wait(0.25); |
| mbed_official | 0:aaf5a9d465fd | 37 | } |
| mbedAustin | 6:fa65447e171b | 38 | } |
