DigitalInOut Hello World

Fork of DigitalInOut_HelloWorld_Mbed by Mbed

Use

The DigitalInOut API can be used to both read and write a digital pin. Use the output() and input() function calls to switch modes and then use just like you would DigitalIn or DigitalOut.

API

API reference.

Import librarymbed

No documentation found.
Committer:
mbedAustin
Date:
Fri Mar 27 20:13:44 2015 +0000
Revision:
4:3f69262115b3
Parent:
3:e4004b2e39ad
Child:
5:65ab82bfa4a6
Added license to main.c file.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbedAustin 4:3f69262115b3 1 /* mbed Example Program
mbedAustin 4:3f69262115b3 2 * Copyright (c) 2006-2014 ARM Limited
mbedAustin 4:3f69262115b3 3 *
mbedAustin 4:3f69262115b3 4 * Licensed under the Apache License, Version 2.0 (the "License");
mbedAustin 4:3f69262115b3 5 * you may not use this file except in compliance with the License.
mbedAustin 4:3f69262115b3 6 * You may obtain a copy of the License at
mbedAustin 4:3f69262115b3 7 *
mbedAustin 4:3f69262115b3 8 * http://www.apache.org/licenses/LICENSE-2.0
mbedAustin 4:3f69262115b3 9 *
mbedAustin 4:3f69262115b3 10 * Unless required by applicable law or agreed to in writing, software
mbedAustin 4:3f69262115b3 11 * distributed under the License is distributed on an "AS IS" BASIS,
mbedAustin 4:3f69262115b3 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
mbedAustin 4:3f69262115b3 13 * See the License for the specific language governing permissions and
mbedAustin 4:3f69262115b3 14 * limitations under the License.
mbedAustin 4:3f69262115b3 15 */
mbed_official 0:0d0417932681 16 #include "mbed.h"
mbed_official 0:0d0417932681 17
mbed_official 0:0d0417932681 18 DigitalInOut pin(p5);
mbed_official 0:0d0417932681 19
mbed_official 0:0d0417932681 20 int main() {
mbed_official 0:0d0417932681 21 pin.output();
mbedAustin 3:e4004b2e39ad 22 pin = 0; // write pin value
mbed_official 0:0d0417932681 23 wait_us(500);
mbed_official 0:0d0417932681 24 pin.input();
mbedAustin 3:e4004b2e39ad 25 // can read pin value here
mbed_official 0:0d0417932681 26 wait_us(500);
mbed_official 0:0d0417932681 27 }