Looking for a device that can produce precise and controlled mechanical movements? Look no further than the servo motor! This nifty gadget operates by utilizing a DC motor, mechanical gearing, and cutting-edge electronics to set the servo’s rotary position via feedback.
Using a servo motor
But what makes the servo so versatile, you might ask? Well, this miniature powerhouse has a multitude of applications – from controlling the steering of remote-controlled models to operating the precise movements of robotic arms. And now, we’re even using it for an indoor plant watering system! – though this is currently undergoing a few design modifications!
By incorporating the servo motor into our plant watering system, we’re able to control the amount of water each plant receives with ease. With just three simple connections – two for DC power (+5V and GND) and one for a control pulse (coloured orange in the picture below) – we can vary the pulse width of the signal to rotate the servo to a specific position, which in turn opens or closes a valve that regulates the flow of water.
To ensure smooth and seamless control, the control pulse is sent periodically every 20ms. For its physical appearance, the micro servo – as shown in the picture – is a compact and convenient size, making it the perfect choice for small-scale projects like our indoor plant watering system.
So whether you’re building a remote-controlled model, a robotic arm, or a plant watering system, the servo motor is a versatile and precise choice that won’t disappoint!
Building a servo tester
The Servo Tester shown here is made from a Raspberry Pi Pico using MicroPython code. The Servo Tester steadily drives the Servo back and forth from one end to the other using a varying control pulse from 0.5ms to 2.5ms.
It should be mentioned that some servos use a smaller pulse range of 0.7ms to 2.3ms. To change the code for this, set the pulse width value from 500 to 700 and change the two “for” lines from “for x in range (1,200):” to “for x in range (1,160):”
The circuit diagram
The code
#Servo Tester GN_18/3/23
#Generates pulses from 0.5ms to 2.5ms
from machine import Pin
from utime import sleep_us,sleep
pulse_width=500 #intial pulse width 0.5ms
led=Pin (25,Pin.OUT)
servo_pulse=machine.Pin(22,machine.Pin.OUT)
while True:
for x in range (1,200):
led.on()
servo_pulse.value(1)
sleep_us(pulse_width)
servo_pulse.value(0)
led.off()
pulse_width +=10
sleep(0.02)
for x in range (1,200):
led.on()
servo_pulse.value(1)
sleep_us(pulse_width)
servo_pulse.value(0)
led.off()
pulse_width -=10
sleep(0.02)