duckietownhsunina / Mbed 2 deprecated example_IR_Sensors

Dependencies:   mbed

main.cpp

Committer:
vidica94
Date:
2017-02-19
Revision:
2:d288340a708d
Parent:
1:58b121ccca27
Child:
3:5844462d5785

File content as of revision 2:d288340a708d:

#include "mbed.h"

/*
   This basic example just shows how to read the output value of a infrared sensor. In this case we used the sensor avaiable on amazon link
   we read the output value as a digital signal , so we can use the InterruptIn to better control the bot.
    WARNING: to catch the target at the right distance it's necessary to calibrate the ir sensor, using the little trimmer on the pcb whith the sensors.
   To calibrate the sensors run the other program
*/

DigitalIn ir(D4);// definition of the pin D4 as digital input


DigitalOut led(LED1);//definition of the green led on the board as digital output

int main()
{
    
    while(1) {
   
        
        printf("lettura = %d\n",ir.read() );
       
      if(ir.read()==1)
        led = 1;
        else
        led=0;
        wait(1.0);
    }
}