|
Raspberry Pi |
x 1 | |
|
Ultrasonic Sensor |
x 1 | |
|
Servo Motor |
x 1 | |
|
PWM Driver |
x 1 |
|
Thonny IDE |
|
|
Raspbian OS |
|
|
Python |
Raspberry Pi + Servo Motor + Ultrasonic Sensor
Hello!
We have prepared a small tutorial with Raspberry Pi + Ultrasonic
Sensor + Servo Motor. I would try another Raspberry Pi application for
beginners; I looked among the pieces I had at my disposal, and found something
interesting; I searched the internet for information about the parts I have,
how to control them individually, and now I will try to combine them to make an
application for learning purposes.
Components used in this project:
- Raspberry Pi;
- Ultrasonic Sensor HC SR-04;
- Servo Motor SG90;
- PCA9685 PWM Driver.
The first step is to install a library, which will help us use
the PWM driver PCA9685 (Figure 1), useful to control a servomotor, an LED or a
dc motor. Information can be found at this link:
https://learn.adafruit.com/adafruit-16-channel-servo-driver-with-raspberry-pi/using-the-adafruit-library.
Figure 1
We start by opening Terminal Window and writing the command:
sudo pip3 install
adafruit-circuitpython-servokit
We are waiting for the package installation to be completed.
The control of the SG 90 servomotor (Figure 2) is easy, we only
need a few program lines written in Thonny IDE:
from
adafruit_servokit import ServoKit
kit = ServoKit
(channels = 16)
We import and initialize the ServoKit class.
Then, to move the actuator to an angle we want, we add the
command:
kit.servo [0] .angle
= 0
Figure 2
The HC SR-04 ultrasonic sensor (Figure 3) is affordable, easy to
use at 5V.
Figure 3
The electronic scheme according to which the connections are
made is the following:
Figure 4
The servomotor is connected to channel 0 of PCA9685; a supply
voltage of 5V is required for the servomotor and the ultrasonic sensor, and a
3.3V for the logic circuit of the PCA9685; PCA9685 driver, SDA and SCL pins
connect SDA and SCL pins on the Raspberry Pi (physical pins 3 and 5); for the
ultrasonic sensor, the Trig pin -> GPIO23 (physical pin 16) and Echo ->
GPIO24 (physical pin 18).
Practical realization of the project (Figure 5):
Figure 5
The distance is displayed in centimeters, with two decimals, the
program is run in Thonny Python (Figure 6):
Figure 6
Thanks to the PCBWay team for this activity!
We expect as much from you!
Success!
Raspberry Pi + Servo Motor + Ultrasonic Sensor
- Comments(0)
- Likes(1)
- Engineer Jan 06,2024
- 0 USER VOTES
- YOUR VOTE 0.00 0.00
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
More by Cristian Pitigoi
- LEDs Stars Hello everyone! I'm signing up for this competition with a small project designed to attract your a...
- Audio amplifier with LM386 (and BASS boost) Audio amplifier with LM386 (and BASS boost)Hello everyone!Circuit descriptionThe LM386 is quite a ve...
- Audio amplifier 25W TDA2030 Audio amplifier 25W TDA2030A fairly well-known and interesting montagePresentationThe presented audi...
- Raspberry Pi Pico Expansion Board Hello everyone!This is my new PCB design. I wanted to share it with you on this platform.This is an ...
- Adjustable voltage power supply Among the most important electronic devices in the electronics laboratory is the voltage source. Thi...
- Digital Clock with AT89C2051 Circuit OperationShort SW2 presses cycle through displaying the current time in HH:MM and MM:SS form...
- Switch based light sensor Hi!The circuit shown can be used to turn on the light in the garden, or some light panels / advertis...
- LM3909 flashing indicator I present to you a circuit which is a little outdated, but quite pleasant for some, I saw that this ...
- The use of IoT technology for monitoring specific electrical parameters of autonomous power systems Hello everyone!A brief introduction of this project.What you see presented here is a home made (or D...
- ESP32 Expansion Board Expansion board for ESP32Hello everyone!This is my new PCB design. I wanted to share it with you on ...
- 4 Digits 7 Segments CC Display Module with 74HC595 Hello! This time I want to present an 7-segment four digit display controlled by two 74HC595.The LED...
- Adjustable voltage power supply Adjustable voltage power supplyAmong the most important electronic devices in the electronics labora...
- ARDUINO LCD 1602 SHIELD + KEYBOARD ARDUINO LCD 1602 SHIELD + KEYBOARDThe LCD1602 shield can be mounted together with an Arduino Nano de...
- Double voltage source Circuit presentationDouble voltage source + 15V / -15V and + 5V / -5V stabilizedThis circuit offers ...
- Monitor for 12V batteries Monitor for equal voltage at the terminals of two 12V batteries.Circuit presentation Most 24V back-u...
- Variable stabilizer for low voltages Variable stabilizer for low voltagesThe presented circuit allows to obtain stabilized voltages betwe...
- Simple Temperature Regulator Simple temperature regulatorCircuit descriptionThe temperature controller uses as a temperature tran...
- Audio balance indicator Technical data: - supply voltage 12-15V; - minimum level of the audible signal applied at the input&...
-
-
-
-
-
-
3D printed Enclosure Backplate for Riden RD60xx power supplies
153 1 1 -
-