esempio IR
Dependencies: mbed
main.cpp
- Committer:
- vidica94
- Date:
- 2017-02-19
- Revision:
- 3:5844462d5785
- Parent:
- 2:d288340a708d
File content as of revision 3:5844462d5785:
#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 potentiometer 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); } }