Controlling a servo motor from a Processing program

From Knowledge Kitchen
Jump to navigation Jump to search


This example shows how to use a Processing application to control a servo motor hooked up to an Arduino. You will control the movement of a servo motor by dragging a red circle left and right on your yellow computer screen.

Dragging a circle on the screen controls the servo motor


The circuit

The circuit used simply involves a servo motor connected to one of the Arduino's analog output pins. Our code assumes we are using pin 5. If you need a refresher on how to connect a servo motor to an Arduino, check out this simple example of a servo controlled from Arduino code.

The Processing code

Processing code for controlling a servo motor


The Arduino code

Arduino code for controlling a servo motor from Processing


What links here