code for sterring wheel interface

Dependencies:   MBC002-DigitalIn

Committer:
leandropg
Date:
Sun May 20 11:33:50 2018 +0000
Revision:
0:4265ec26da85
Child:
1:1bd5272d7a1f
MBC002 - DigitalIn * This example use the DigitalIn function

Who changed what in which revision?

UserRevisionLine numberNew contents of line
leandropg 0:4265ec26da85 1 /**
leandropg 0:4265ec26da85 2 * MBC002 - DigitalIn
leandropg 0:4265ec26da85 3 * This example use the DigitalIn function
leandropg 0:4265ec26da85 4 * 20 May 2018 - Mbed Colombia - http://mbedcolombia.wordpress.com/
leandropg 0:4265ec26da85 5 *
leandropg 0:4265ec26da85 6 * Board: ST-Nucleo-F446RE - https://os.mbed.com/platforms/ST-Nucleo-F446RE/
leandropg 0:4265ec26da85 7 *
leandropg 0:4265ec26da85 8 * Copyright [2018] [Leandro Perez Guatibonza / leandropg AT gmail DOT com]
leandropg 0:4265ec26da85 9 *
leandropg 0:4265ec26da85 10 * Licensed under the Apache License, Version 2.0 (the "License");
leandropg 0:4265ec26da85 11 * you may not use this file except in compliance with the License.
leandropg 0:4265ec26da85 12 * You may obtain a copy of the License at
leandropg 0:4265ec26da85 13 *
leandropg 0:4265ec26da85 14 * http://www.apache.org/licenses/LICENSE-2.0
leandropg 0:4265ec26da85 15 *
leandropg 0:4265ec26da85 16 * Unless required by applicable law or agreed to in writing, software
leandropg 0:4265ec26da85 17 * distributed under the License is distributed on an "AS IS" BASIS,
leandropg 0:4265ec26da85 18 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
leandropg 0:4265ec26da85 19 * See the License for the specific language governing permissions and
leandropg 0:4265ec26da85 20 * limitations under the License.
leandropg 0:4265ec26da85 21 */
leandropg 0:4265ec26da85 22 #include "mbed.h"
leandropg 0:4265ec26da85 23
leandropg 0:4265ec26da85 24 // LED connected Pin PC_0
leandropg 0:4265ec26da85 25 DigitalOut led(PC_0);
leandropg 0:4265ec26da85 26
leandropg 0:4265ec26da85 27 // Push-Button connected Pin PC_3
leandropg 0:4265ec26da85 28 DigitalIn pushButton(PC_3);
leandropg 0:4265ec26da85 29
leandropg 0:4265ec26da85 30 // Main Loop runs in its own thread in the OS
leandropg 0:4265ec26da85 31 int main() {
leandropg 0:4265ec26da85 32
leandropg 0:4265ec26da85 33 // Active Pull-Up Resistor
leandropg 0:4265ec26da85 34 pushButton.mode(PullUp);
leandropg 0:4265ec26da85 35
leandropg 0:4265ec26da85 36 // Inifite Loop
leandropg 0:4265ec26da85 37 while(1) {
leandropg 0:4265ec26da85 38
leandropg 0:4265ec26da85 39 // Check Push-Button
leandropg 0:4265ec26da85 40 if(pushButton == 0) {
leandropg 0:4265ec26da85 41
leandropg 0:4265ec26da85 42 // LED Turn-On
leandropg 0:4265ec26da85 43 led = 1;
leandropg 0:4265ec26da85 44
leandropg 0:4265ec26da85 45 } else {
leandropg 0:4265ec26da85 46
leandropg 0:4265ec26da85 47 // LED Turn-Off
leandropg 0:4265ec26da85 48 led = 0;
leandropg 0:4265ec26da85 49 }
leandropg 0:4265ec26da85 50 }
leandropg 0:4265ec26da85 51 }