Arduino 5 Minute Tutorials: Lesson 4 - IR Distance Sensor & Push Button

@Laurens Fobe: Since this is an in-depth technical question, we recommend that you post it on our forum instead, such as here.

I have never used IR proximity sensors and am very new to Arduino, but I simply want to turn on LEDs when an object is in range of the sensor, and off when it is out of range. I have the IR Proximity Sharp GP2Y0A02YK0F (its range is 15cm - 150cm) where can I find the code for this? I’m sure it is not difficult but like I said, I have never dealt with these. Perhaps a different sensor is more appropriate for this as I have noticed most people on forums are using it for measuring distances, not controlling LEDs etc.
Thanks!

@Lily We are not aware of “plug and play” code for what you want to do. The answer would involve knowing / understanding your setup and then creating custom code, we can only advise that you start learning about Arduino programming. One line will read the sensor value via analog input, another will compare it to a distance range, and a third will trigger the LED using a digital pin.

if possible to configure both IR And Bluetooth sensor to a single arduino ?

@Elumalai IR would connect to either an analog or digital sensor, whereas Bluetooth would connect to serial. IR is a distance sensor, whereas Bluetooth is wireless communication.

can u give code of about 1 meter to 2 meter

@milik You can use certain infrared or ultrasonic sensors to detect objects at 1-2m.

I won’t learn use Arduino ir module using?

@hasintha Unfortunately we do not understand your question.

sir can you plz help me, basically i am going to make wall painting robot using arduino,so first i have to build up my robot that can understand that there is wall and it stop there then how can i do that

@Narayan You can use normal distance sensors. We strongly suggest however that the robot start on the wall and not on the floor.

My project is involving the use of infrared sensors to serve as beacons for my mobile robot, these beacons are four in number (infrared transmitters) and should have one receiver sensor on the mobile robot. Can you pls help give me a site where I can get to purchase such combination. Four of the transmitter sensors should transmit at different frequencies and should be identified by the receiver sensor.

@Tunde Isaac Oyegbade You can find IR Tx / Rx here: https://www.robotshop.com/en/infrared-communication-control.html Alternatively, try Digikey / Mouser electronics.

Hello, can i use this step for ultrasonic sensor too?

@anila Most ultrasonic sensors use I2C as opposed to analog or digital.

sir, I want to know the coding when ir and distance sensors are connected …that both have to sense @ same time

@imran ahmed It depends on which sensor you use. There is sample code for analog (most infrared) and I2C (most ultrasonic) if you use Arduino.

hi sir, iam a E.C.E third year student .Could you suggest me a project in real time application.

@maniroop There are many - are you simply looking to get experience in programming? Do you have any specific criteria?

I have 30cm Infrared Distance Sensor - Product Code : RB-See-434
So, how connect this to Arduino ?