LGZD:sensor

Dependencies:   mbed

main.cpp

Committer:
e58136782000
Date:
2017-10-27
Revision:
0:1bf4445f640f

File content as of revision 0:1bf4445f640f:

#include "mbed.h"

DigitalOut ledpin(LED1); 
DigitalIn  sensor_in(D4);
Serial serial(USBTX, USBRX);
int main(){
      
    while(1) {
        // LEDs are ON
        if(sensor_in)
        {
            ledpin = 1;
            serial.printf("LED:ON\n");     
            wait(1.2);
        }
        else
        {
        // LEDs are OFF
            ledpin = 0;
           serial.printf("LED:OFF\n");
            wait(1.4);
        }
  }
}