PortIn Hello World

Dependencies:   mbed

Fork of PortIn_HelloWorld by Mbed

Note

Depending on your board your ports may be named as numbers or as letters. For example the NXP boards have Port1, Port2, Port3...etc but the Freescale boards have PortA, PortB, PortC, PortD. Please refer to the boards Platform page to find out which one your board uses.

API

API reference.

Import librarymbed

No documentation found.
Committer:
mbedAustin
Date:
Fri Mar 27 20:15:02 2015 +0000
Revision:
2:e78266d48649
Parent:
0:92064442fd12
Added license to main.c file.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbedAustin 2:e78266d48649 1 /* mbed Example Program
mbedAustin 2:e78266d48649 2 * Copyright (c) 2006-2014 ARM Limited
mbedAustin 2:e78266d48649 3 *
mbedAustin 2:e78266d48649 4 * Licensed under the Apache License, Version 2.0 (the "License");
mbedAustin 2:e78266d48649 5 * you may not use this file except in compliance with the License.
mbedAustin 2:e78266d48649 6 * You may obtain a copy of the License at
mbedAustin 2:e78266d48649 7 *
mbedAustin 2:e78266d48649 8 * http://www.apache.org/licenses/LICENSE-2.0
mbedAustin 2:e78266d48649 9 *
mbedAustin 2:e78266d48649 10 * Unless required by applicable law or agreed to in writing, software
mbedAustin 2:e78266d48649 11 * distributed under the License is distributed on an "AS IS" BASIS,
mbedAustin 2:e78266d48649 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
mbedAustin 2:e78266d48649 13 * See the License for the specific language governing permissions and
mbedAustin 2:e78266d48649 14 * limitations under the License.
mbedAustin 2:e78266d48649 15 */
mbedAustin 2:e78266d48649 16
mbedAustin 2:e78266d48649 17
mbed_official 0:92064442fd12 18 // Switch on an LED if any of mbed pins 21-26 is high
mbed_official 0:92064442fd12 19
mbed_official 0:92064442fd12 20 #include "mbed.h"
mbed_official 0:92064442fd12 21
mbed_official 0:92064442fd12 22 PortIn p(Port2, 0x0000003F); // p21-p26
mbed_official 0:92064442fd12 23 DigitalOut ind(LED4);
mbed_official 0:92064442fd12 24
mbed_official 0:92064442fd12 25 int main() {
mbed_official 0:92064442fd12 26 while(1) {
mbed_official 0:92064442fd12 27 int pins = p.read();
mbed_official 0:92064442fd12 28 if(pins) {
mbed_official 0:92064442fd12 29 ind = 1;
mbed_official 0:92064442fd12 30 } else {
mbed_official 0:92064442fd12 31 ind = 0;
mbed_official 0:92064442fd12 32 }
mbed_official 0:92064442fd12 33 }
mbed_official 0:92064442fd12 34 }