MBC002 - DigitalIn * This example use the DigitalIn function

Dependents:   steering_wheel_controls_TO_KEENWOOD_RADIO_INFRARED_INTERFACE NUCLEO_TRANSMITS_8_INFRARED_COMMANDS

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 /**
00002  * MBC002 - DigitalIn
00003  * This example use the DigitalIn function
00004  * 20 May 2018 - Mbed Colombia - http://mbedcolombia.wordpress.com/
00005  *
00006  * Board: ST-Nucleo-F446RE - https://os.mbed.com/platforms/ST-Nucleo-F446RE/
00007  *
00008  * Copyright [2018] [Leandro Perez Guatibonza / leandropg AT gmail DOT com]
00009  *
00010  * Licensed under the Apache License, Version 2.0 (the "License");
00011  * you may not use this file except in compliance with the License.
00012  * You may obtain a copy of the License at
00013  * 
00014  *    http://www.apache.org/licenses/LICENSE-2.0
00015  * 
00016  * Unless required by applicable law or agreed to in writing, software
00017  * distributed under the License is distributed on an "AS IS" BASIS,
00018  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00019  * See the License for the specific language governing permissions and
00020  * limitations under the License.
00021  */
00022 #include "mbed.h"
00023 
00024 // LED connected Pin PC_0
00025 DigitalOut led(PC_0);
00026 
00027 // Push-Button connected Pin PC_3
00028 DigitalIn pushButton(PC_3);
00029 
00030 // Main Loop runs in its own thread in the OS
00031 int main() {
00032    
00033     // Active Pull-Up Resistor
00034     pushButton.mode(PullUp);
00035    
00036     // Inifite Loop
00037     while(1) {
00038         
00039         // Check Push-Button
00040         if(pushButton == 0) {
00041             
00042             // LED Turn-On
00043             led = 1;
00044             
00045         } else {
00046             
00047             // LED Turn-Off
00048             led = 0;
00049         }
00050     }
00051 }