top of page

Reverse Mode Sensor System

This is a simple project that depicts the reverse system of a car. It will help the driver when reversing their car. They won't have to exit the car in order to check if the car has packed in the parking lot

COMPONENTS

HC-SR04 ULTRASONIC SENSOR

Ultrasonic-Sensor.webp

HC-SR04 stands for High-Conductance ultrasonic sensor, which consists of a transmitter and receiver. The sensor measures how far things are without touching them, and it uses sound waves to get the measurements right. It can work well when things are between two to four centimeters away. Just like other tools that measure distances, this sensor doesn’t harm objects. So, it’s good for things that are around two to four centimeters away.

The HC-SR04 emits ultrasonic sounds that are inaudible to humans, aiding in distance measurement and object positioning. The sensor can feel things within a specific area. To get it to function, you need to lift the Trig pin while keeping the Echo pin down for roughly 10 seconds.

In this project, the HC-SR04 is used to measure distance as discussed above and sends it to the Raspberry Pi pico for processing

RASPBERRY PI PICO

Rasp.png

The Raspberry Pi pico is a microcontroller board with an RP2040 microcontroller chip. The Pico is notable for its low cost, small form factor, and versatility, making it suitable for a wide range of embedded projects and applications. It features a dual-core ARM Cortex-M0+ processor, ample memory, GPIO pins for interfacing with sensors and peripherals, and support for various programming languages, including MicroPython and C/C++.

The Raspberry was used in this project to accept distance measurement from the HC-SR04 and in turn display the same and other warnings on the OLED 

OLED DISPLAY

OLEDi_edited_edited.jpg

OLED, or Organic Light-Emitting Diode, displays are a type of screen technology that uses organic compounds to emit light when an electric current is applied. An OLED display module encompasses a compact electronic component that integrates an OLED display panel along with the necessary control circuitry and connectors into a single package. These modules provide an easy way to incorporate OLED technology into electronic projects without needing to deal with the complexities of designing and driving the display from scratch.

In this project, the OLED is used to display the distance as well as warnings when a certain distance is achieved

BUZZER

Piezo-Buzzer_edited.png

A buzzer is understood as a device that creates an audible tone under the influence of an applied external voltage. This output may either be in the form of a buzzing or a beeping sound. This is a result of the induced rapid movements created in the diaphragm of the buzzer

PROGRAM CODE

from machine import Pin, SPI
import utime
import math
from ssd1306 import SSD1306_SPI

import framebuf

'''
RSP Pico  |  OLED
16        |  CS
17        |  DC
18        |  SCK
19        |  MOSI
20        |  RST


RSP Pico  | HC-SR04
14        | Trigger
13        | Echo

LED1 stands in for the buzzer in this case. It is connected to pin 11 of RSP Pico


'''

WIDTH  = 128                                            # oled display width
HEIGHT = 64
# oled display height

trigger = Pin(
14, Pin.OUT)
echo = Pin(
13, Pin.IN)
led1 = Pin(
11, Pin.OUT)
spi = SPI(
0, 100000, mosi=Pin(19), sck=Pin(18))
oled = SSD1306_SPI(
128, 64, spi, Pin(17),Pin(20), Pin(16))

def get_distance():
   trigger.low()
   utime.sleep_us(
2)
   trigger.high()
   utime.sleep_us(
5)
   trigger.low()
   
while echo.value() == 0:
       signaloff = utime.ticks_us()
   
while echo.value() == 1:
       signalon = utime.ticks_us()
   timepassed = signalon - signaloff
   distance = (timepassed *
0.0343) / 2
   print("Distance is ",distance,"cm")
   
return distance

while True:
    
    ret_val = get_distance()
    sun =
str(ret_val)
    

 
  if ret_val>0 and ret_val<30:
       
if ret_val>20:
            oled.fill(
0)
            oled.show()
            oled.text(
"Close!!", 1,1)
            oled.text(sun,
0, 25)
            oled.text(
"cm", 65,25)
            oled.show()
            led1.value(
1)
            utime.sleep(
0.35)
            led1.value(
0)
            utime.sleep(
0.35)
       
else:
            oled.fill(
0)
            oled.show()
            oled.text(
"Very Close!", 1,1)
            oled.text(sun,
0, 25)
            oled.text("cm",
65,25)
            oled.show()
            led1.value(
1)
            utime.sleep(
0.05)
            led1.value(
0)
            utime.sleep(
0.05)
        
   
else:
         led1.value(
1)
         oled.fill(
0)
         oled.show()
         oled.text(
"Distance is:", 1,1)
         oled.text(sun,
0, 25)
         oled.text(
"cm", 65,25)
         oled.show()
         utime.sleep(
2.0)
   
    utime.sleep(
0.0)

DEMO

IMG_0015.JPG
bottom of page