Arduino_DigitalInputPullup sample code ported.

Dependencies:   mbed

Fork of InterruptIn_HelloWorld by mbed official

main.cpp

Committer:
homayoun
Date:
2014-09-03
Revision:
1:880e692b96e2
Parent:
0:7a20a6aa1f5e

File content as of revision 1:880e692b96e2:

#include "mbed.h"

DigitalIn sensor(D2,PullUp);
Serial pc(SERIAL_TX, SERIAL_RX);
DigitalOut led(D13);

void setup()
{
    pc.baud(9600);
}

void loop()
{
    int sensorVal = sensor.read();
    pc.printf("%f\n", sensorVal);

    if (sensorVal == 1) led = 1; // turn LED on:
    else led = 0; // turn LED off:
}

int main()
{
    setup();
    while(1) loop();
}