Introduction: Raspberry Pi Pico and Proximity Sensor
INTRODUCTION:
In this instructables I am going to show you how you can interface the IR proximity sensor with raspberry pi pico. Combining the raspberry pi pico board and the IR Proximity sensor, I create an obstacle detector that detects the objects whenever they pass through in front of the sensor. So let's get started.
Supplies
Electronic Hardware:
https://quartzcomponents.com?sca_ref=3671286.DzEptz4I3w
Raspberry Pi Pico:
https://quartzcomponents.com/products/raspberry-pi-pico?_pos=3&_sid=ca1f50171&_ss=r
IR Proximity sensor:
Buzzer(small size):
Jumper Wires:
https://quartzcomponents.com/products/65pcs-breadboard-jumper-cable?_pos=7&_sid=266bff35d&_ss=r
Bread Board:
Micro-B USB cable:
https://quartzcomponents.com/products/raspberry-pi-cable-for-charging?_pos=1&_sid=82b0f1ecb&_ss=r
Step 1: IR Proximity Sensor
OVERVIEW:
An IR (infrared) proximity sensor is a type of sensor that detects the presence of objects or obstacles within a certain range by emitting infrared radiation and measuring the amount of reflection or absorption of the signal. These sensors emit a beam of IR light and measure the time it takes for the light to bounce back to the sensor after hitting an object. sensor is an active sensor that detects obstacles(objects) whenever they pass through in front it. We can also adjust the sensitivity of the Proximity sensor. Proximity sensors are of following types
- Capacitive Proximity Sensor
- Inductive Proximity Sensor
- IR Proximity Sensor
- Ultrasonic Proximity Sensor
Here, I am going to use IR proximity sensor.
Working of IR Proximity Sensor:
An IR (infrared) proximity sensor is a type of sensor that detects the presence of objects or obstacles within a certain range by emitting infrared radiation and measuring the amount of reflection or absorption of the signal. These sensors emit a beam of IR light and measure the time it takes for the light to bounce back to the sensor after hitting an object.
Step 2: Making a Prototype Circuit on Bread Board
To make a prototype circuit on a bread board, we can take the help of the given schematic diagram. First fix the pico board and IR proximity sensor on the bread board. Now connect the pins of the IR proximity sensor as following wiring scheme:
VCC---------->VBUS
GND---------->GND
DO----------> GPIO-15
After connecting the IR proximity sensor. we are ready to connect the buzzer. Fix the buzzer on the bread board and connect its pins according to following wiring scheme:
+V---------->GPIO-14
GND----------GND
Finally our prototype is done, Connect the raspberry pi pico to the laptop with USB Micro-B cable.
Step 3: Writing a Micro Python Program
from machine import Pin
led = Pin(25, Pin.OUT) #set GPIO-25 pin mode as OUTPUT
sensor = Pin(15, Pin.IN) #set GPIO-25 pin mode as INPUT
buzzer = Pin(14, Pin.OUT) #set GPIO-25 pin mode as OUTPUT
while True:
if sensor.value() == 0: #read the value of the sensor pin and compare it with 0
led.value(1) #set led pin HIGH if sensor pin is LOW
buzzer.value(1) #set buzzer pin HIGH if sensor pin is LOW
else:
led.value(0) #set led pin HIGH if sensor pin is HIGH
buzzer.value(0) #set buzzer pin HIGH if sensor pin is HIGH