Let's start with just a servo and the REPL, then we can add in a sensor. Use the diagram from the previous section as a reference to wire up a servo, and use pin 6 for signal.
Before we write our program, let's take a look at some of the options the
Servo object constructor gives us. You can set an arbitrary range by passing
[min, max] to the
range property. This is great for low quality servos that have trouble at very low and very high values.
type property is also important. We'll be using a standard servo, but you'll need to set this to
continuous if you're using a continuous servo. Since
standard is the default, we can leave this out for now.
offset property is important for calibration. If ...