code for sterring wheel interface

Dependencies:   MBC002-DigitalIn

main.cpp

Committer:
leandropg
Date:
2018-05-20
Revision:
0:4265ec26da85
Child:
1:1bd5272d7a1f

File content as of revision 0:4265ec26da85:

/**
 * MBC002 - DigitalIn
 * This example use the DigitalIn function
 * 20 May 2018 - Mbed Colombia - http://mbedcolombia.wordpress.com/
 *
 * Board: ST-Nucleo-F446RE - https://os.mbed.com/platforms/ST-Nucleo-F446RE/
 *
 * Copyright [2018] [Leandro Perez Guatibonza / leandropg AT gmail DOT com]
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *    http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
#include "mbed.h"

// LED connected Pin PC_0
DigitalOut led(PC_0);

// Push-Button connected Pin PC_3
DigitalIn pushButton(PC_3);

// Main Loop runs in its own thread in the OS
int main() {
   
    // Active Pull-Up Resistor
    pushButton.mode(PullUp);
   
    // Inifite Loop
    while(1) {
        
        // Check Push-Button
        if(pushButton == 0) {
            
            // LED Turn-On
            led = 1;
            
        } else {
            
            // LED Turn-Off
            led = 0;
        }
    }
}