The example program for mbed pin-compatible platforms

Dependencies:   mbed

Fork of mbed_blinky by Mbed

main.cpp

Committer:
koji333
Date:
2014-10-06
Revision:
7:97872775e085
Parent:
4:81cea7a352b0

File content as of revision 7:97872775e085:

#include "mbed.h"

DigitalIn diginput(p7);
DigitalOut led1(LED1);
DigitalOut led2(LED2);
 /*
 Wire a mechanical button so that it connects the pin 'p7' and GND.
 Then pressing the mechanical button causes 'diginput' ==  0.
 The LED 'led1' lights while the mechanical button is not pressed.
 The LED 'led2' blinks while the mechanical button is pressed.
 */
int main() {
    while(1) {
        if(diginput) { // the mechanical button is not pressed.
            led1 = 1;
            led2 = 0;            
        } else {       // the mechanical button is pressed.
            led1 = 0;
            led2 = !led2;
        };
        wait(0.25);
    }
}