Electorials Electronics
Published © GPL3+

Project 006: Arduino Infrared Proximity Sensor Project

A very basic project composing of a Sharp infrared proximity sensor hooked up to an Arduino with a few lines of code; for a perfect newbie.

BeginnerProtip12 minutes22,011
Project 006: Arduino Infrared Proximity Sensor Project

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
You could use any other Arduino board as well. The Keyestudio Uno is used in this example.
×1
SparkFun Sharp Infrared Proximity Sensor (2Y0A21)
×1
Jumper wires (generic)
Jumper wires (generic)
3 Male to Male Jumper Wires.
×3
USB-A to B Cable
USB-A to B Cable
Depends on the Arduino.
×1
NextPCB
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

Circuit Diagram

Schematics

Code

Arduino Sharp Infrared Proximity Sensor Project Code

C/C++
int IRpin = 1;                                    
void setup() {
  Serial.begin(9600);                             
}
void loop() {
  float volts = analogRead(IRpin)*0.0048828125;   
  float distance = 65*pow(volts, -1.10);   
  Serial.print(distance);     
  Serial.println(" cm");
  delay(100);                                     
}

Credits

Electorials Electronics
85 projects • 67 followers
I'm an electronic hobbyist interested in anything, from Arduino to drones. I plan to educate people with the content on my website.

Comments