esempio IR
Dependencies: mbed
Diff: main.cpp
- Revision:
- 0:1a9d324dc172
- Child:
- 1:58b121ccca27
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sat Feb 18 18:49:04 2017 +0000 @@ -0,0 +1,29 @@ +#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 want to read the output value as a digital signal , so we can use the InterruptIn to better control the bot. + WARNING: 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); + } +}