Servo motors
Figure 1: Standard servo
A standard servo rotates over 180 and is useful for controlling actuators such as valves or automatic door openers. Please see the notes for more information.
Firstly, the Particle development environment simplifies things a little
in comparison to Arduino because the servo object is built-in. With an
Arduino you need to explicitly include a servo library. On the hardware
side though, a standard servo requires 5V to operate and the Argon is a
3.3V device. If your Argon is connected to a computer or a power outlet
via USB, then you can take 5V from the VBUS
pin to power the servo.
Another complication is that controlling a servo requires pulse-width
modulation (PWM) which is only available
on some of the Argon's digital pins. Figure 2 shows you how to connect up
your servo using VBUS
.
Figure 2: Breadboard layout using VBUS
Next, go to the Particle Web IDE and paste the code below into the editor.
Give your file a name and save it using the folder icon in the navigation panel.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
|
You can see the messages displayed on the serial port by starting the serial monitor with the command
1 |
|
If you need the servo to work reliably when the Argon is not connected to your computer, you will need to provide a second source of power. Usually this is some form or battery - a pack of four AA batteries, for example, provide a combined voltage of 6V. Please refer to the notes for further information.