1. Activity Name:
Displaying Distance Using Ultrasonic Sensor on OLED Display
2. Materials Required:
- Arduino Uno/Nano
- Ultrasonic Sensor (HC-SR04)
- OLED Display (SSD1306 - 0.96” I2C)
- Connecting Wires
- Breadboard (Optional)
3. Explanation:
This activity involves measuring the distance of an object using an HC-SR04 ultrasonic sensor and displaying the measured distance on an OLED screen using an Arduino. The ultrasonic sensor emits sound waves, calculates the time taken for the waves to bounce back, and converts it into distance using the speed of sound formula. The OLED screen then displays the real-time distance in centimeters.
Working Principle:
- The HC-SR04 sensor emits ultrasonic waves through its TRIG pin.
- The waves reflect back after hitting an obstacle and are received by the ECHO pin.
- The time difference between sending and receiving waves is calculated.
- The Arduino converts this time into distance using the formula:
- The calculated distance is displayed on the OLED screen in real time.
4. Connections:
Component | Arduino Pin |
---|---|
Ultrasonic Sensor TRIG | D9 |
Ultrasonic Sensor ECHO | D10 |
OLED Display VCC | 5V |
OLED Display GND | GND |
OLED Display SDA | A4 (SDA) |
OLED Display SCL | A5 (SCL) |
5. Conclusion:
This project successfully demonstrates real-time distance measurement using an ultrasonic sensor and an OLED display. Students learned about sensor interfacing, real-time data visualization, and practical applications such as obstacle detection, smart parking, and automation systems. The hands-on approach sparked interest in sensor-based automation and practical electronics applications.
Code: