Creating distance of the target object in the range of (20-150) cm detect program using Arduino UNO
Required Components
- Arduino Uno Board -1 no
- Sharp IR 2Y0A02 F 5x sensor -1 no
- Data Cable -1 no
- Jumper wires -3 no
Circuit
Steps
- Make sure the components are working properly.
- Connect Sharp distance Sensor board VCC, GND to 5V, GND of Arduino Uno Board.
- Connect Sharp IR 2Y0A02 F5x sensor Board data pin to the Arduino Uno Board A0 pin.
- Check the Arduino program.
- Check the Circuit Connections.
- Run the Arduino program.
Arduino Program
#include <SharpIR.h>
#define ir A0
#define model 20150
SharpIR SharpIR(ir, model);
void setup()
{
Serial.begin(9600);
}
void loop()
{
delay(2000);
unsigned long pepe1=millis();
int dis=SharpIR.distance();
Serial.print("Mean distance: ");
Serial.println(dis);
unsigned long pepe2=millis()-pepe1;
Serial.print("Time taken (ms): ");
Serial.println(pepe2);
}
Usage
- Touch-less switch (Sanitary equipment, Control of illumination, etc., )
- Sensor for energy saving (ATM, Copier, Vending machine, Laptop computer, LCD monitor)
- Amusement equipment (Robot, Arcade game machine)