DigitalIn Hello World

Fork of DigitalIn_HelloWorld_Mbed by Mbed

Use

The DigitalIn API is used to read a digital pin. The value will be either 0 or 1. Buttons and switches are some of the more common digital inputs.

API

API reference.

Import librarymbed

No documentation found.
Committer:
mbedAustin
Date:
Fri Mar 27 20:13:29 2015 +0000
Revision:
4:9b20ef58e04c
Parent:
3:e2f865861a7a
Child:
5:fa65447e171b
Added license to main.c file.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbedAustin 4:9b20ef58e04c 1 /* mbed Example Program
mbedAustin 4:9b20ef58e04c 2 * Copyright (c) 2006-2014 ARM Limited
mbedAustin 4:9b20ef58e04c 3 *
mbedAustin 4:9b20ef58e04c 4 * Licensed under the Apache License, Version 2.0 (the "License");
mbedAustin 4:9b20ef58e04c 5 * you may not use this file except in compliance with the License.
mbedAustin 4:9b20ef58e04c 6 * You may obtain a copy of the License at
mbedAustin 4:9b20ef58e04c 7 *
mbedAustin 4:9b20ef58e04c 8 * http://www.apache.org/licenses/LICENSE-2.0
mbedAustin 4:9b20ef58e04c 9 *
mbedAustin 4:9b20ef58e04c 10 * Unless required by applicable law or agreed to in writing, software
mbedAustin 4:9b20ef58e04c 11 * distributed under the License is distributed on an "AS IS" BASIS,
mbedAustin 4:9b20ef58e04c 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
mbedAustin 4:9b20ef58e04c 13 * See the License for the specific language governing permissions and
mbedAustin 4:9b20ef58e04c 14 * limitations under the License.
mbedAustin 4:9b20ef58e04c 15 */
mbed_official 0:aaf5a9d465fd 16 #include "mbed.h"
mbed_official 0:aaf5a9d465fd 17
mbed_official 0:aaf5a9d465fd 18 DigitalIn enable(p5);
mbed_official 0:aaf5a9d465fd 19 DigitalOut led(LED1);
mbed_official 0:aaf5a9d465fd 20
mbedAustin 3:e2f865861a7a 21 // blink LED when enable line is high
mbed_official 0:aaf5a9d465fd 22 int main() {
mbed_official 0:aaf5a9d465fd 23 while(1) {
mbed_official 0:aaf5a9d465fd 24 if(enable) {
mbed_official 0:aaf5a9d465fd 25 led = !led;
mbed_official 0:aaf5a9d465fd 26 }
mbed_official 0:aaf5a9d465fd 27 wait(0.25);
mbed_official 0:aaf5a9d465fd 28 }
mbed_official 0:aaf5a9d465fd 29 }