Distance + Speed Meter Project.
The objective of this project is to create a multi-function measurement system using an Arduino Nano/UNO, an ultrasonic sensor, an IR sensor, and an OLED display.
The system provides three readings:
- 📏 Ultrasonic distance
- 🚀 Ultrasonic-based speed
- ⚡ IR-based speed
The readings are displayed on a 128×64 OLED display.
Supplies
Deshbot shield
Arduino Nano/UNO
HC-SR04 ultrasonic sensor
IR sensor module
0.96-inch 128×64 OLED display
Jumper wires
Pin Connections
Pin Connections
HC-SR04 Ultrasonic Sensor
HC-SR04Arduino
VCC - 5V
GND - GND
TRIG - A0
ECHO - d13
IR Sensor
IR SensorArduino
VCC - 5V
GND - GND
OUT - D9
OLED Display
OLEDArduino
VCC - 5V
GND - GND
SDA - A4
SCL - A5
Working Principle
1. Ultrasonic Distance
The HC-SR04 sends an ultrasonic pulse toward an object. The pulse reflects from the object and returns to the sensor.
The Arduino measures the time taken by the pulse to return and calculates the distance.
The OLED displays the distance in centimeters.
Example:
2. Ultrasonic Speed
The Arduino continuously measures the ultrasonic distance.
By comparing the current distance with the previous distance and measuring the time between measurements, the system estimates how quickly the distance is changing.
The estimated speed is displayed in km/h.
Example:
3. IR Speed
The IR sensor detects an object when it passes in front of the sensor.
The Arduino measures the time between IR detections and uses a predefined reference distance to calculate an estimated speed.
Example:
OLED Display
Because the OLED is 128×64 pixels, the system uses three display screens.
Screen 1 – Distance
Screen 2 – Ultrasonic Speed
Screen 3 – IR Speed
The display automatically changes between the screens every 2 seconds.
Software
The project uses:
- Arduino C/C++
- Wire library
- Adafruit GFX library
- Adafruit SSD1306 library
Working Flow
Downloads
Conclusion
This project combines an HC-SR04 ultrasonic sensor, IR sensor, Arduino Nano/UNO, and OLED display to create a multifunction measurement system.
It demonstrates how different sensors can be used together to measure distance and speed and display the results on an OLED screen.