|
|
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 cris 🙂
-
Dynamic decoration with LEDs and more
Hello everyone!As you can see in the title, we have a circuit with LEDs, many LEDs, it's a 4x4 LEDs ...
-
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!UPDATE!!!I made some changes, routing in particular, and freed up the board of a few ...
-
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 ...
-
A DIY charger for 12V battery
Hello everyone!I present to you a project that really didn't reach its final state, until recently. ...
-
ESP01 board
Hello PCBWayers!You probably know that ESP01S/01 boards can be a little difficult to use in an easie...
-
ESP12F Board
Hello makers!Some time ago I had a shopping coupon and I thought about making some simple PCBs with ...
-
ATMega32 Board
Hi !I remembered this simple project I made for myself, you can use it with an ATMega32 or ATMega16 ...
-
AT90CAN128
Hello makers!Here is a guy who likes to build various, small, electronic circuits, and through this ...
-
PCBWay 11th Badge Design
Hello PCBwayers!I'm here to participate in the PCBWay 11th Badge Design Contest and after a few idea...
-
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...
-
-
AEL-2011 Power Supply Module
320 0 1 -
AEL-2011 50W Power Amplifier
292 0 1 -
-
-
Custom Mechanical Keyboard
562 0 0 -
Tester for Touch Screen Digitizer without using microcontroller
228 2 2 -
Audio reactive glow LED wristband/bracelet with NFC / RFID-Tags
233 0 1 -
-
-







