ServoOut

ServoOut.swf-4Set the rotational position of a servo motor

Standard Servos

The ServoOut widget controls the position of a standard servo motor within a 180 degree range of rotation (greater than 180 degree servos are available). Servos are typically used to precisely position something mechanical by rotating to a specific angle.

  • A 0 value will position the motor to one extreme
  • 90 will position it in the middle
  • 180 will position it to the other extreme

Continuos Servos

When using a “continuous” servo, the behavior is different. These are modified servos that will turn continuously in either direction, and cannot be set to a specific position. Instead, the value sent to them determines the direction and speed of the rotation.

  • 90 (plus or minus a few degrees depending on the individual servo) value will tell the servo to stop moving
  • 0 sets the highest speed in one direction
  • 180 sets the the highest speed in the other direction

See below for details on how to connect a servo.

On Screen Features

  • connect: Establishes a connection with the specified microcontroller
  • in: shows the instance name of the inputSource, and the values received from it
  • arrow buttons: These allow you to manually control the servo by increasing or decreasing the position

Parameters

  • Screenshot_7_6_14__4_17_PMcontroller – Determines which kind of device the widget communicates with: Arduino or iotnREST.
  • controllerIP – Sets the IP address used to communicate with OSC or iotnREST.
  • controllerOutputNum – Sets the output port on the controller – starts at 0 to use the first port on the controller.
  • controllerPort – Sets the IP Port used to communicate with OSC
  • inputSource – The instance name of the source the widget listens to, e.g AnalogIn.
  • invisible: If set to “true” or checked, the widget will disappear when the Flash movie is run – NOTE: you can make all the widgets invisible interactively when the Flash moving is running simply by pressing the backslash key “\”.
  • multiplier – This number is multiplied with the raw input number from the controller, if set to OSC, hubFeed, or accelerometer. Many OSC devices and software provide fractional values from 0-1. To work with other toolkit widgets, these numbers should be scaled up to an integer range, e.g. by setting multiplier to 1023.
  • remoteHubIP – This sets the IP address of the Hub where the widget will get input values from a microcontroller. Normally this would be 127.0.0.1 for the Hub running locally. But set this to the IP address of another computer running a HUB, e.g. to access devices connected to that computer. Note that even if you are using a remote Hub, the Hub application must also be running locally on the same machine as the widgets.
  • serialPort – For widgets set to communicate with an Arduino or XBee, the USB serial port name that the device is connected to. On the Mac, you can leave the default (/dev/cu.usb*) if only one device is hooked up. On the PC, replace this with the COM port used, e.g. COM7. For more detailed info on how to set this parameter, see the common features for all widgets discussion here.
  • servoSpeed: Make Controller Only – Sets the speed of servo motion if the “speed” button is on. The highest number (1023) is the fastest setting, the lowest number (0) is very slow. For the Make Controller, the actual usable numbers range from 0-14. Above that, the speed is the same as full speed with Speed Control off. Make Controller only, not Arduino.
    servoSpeedSet: Make Controller Only – turns on speed control as set by the Servo Speed parameter.
  • urlString – This text is used for iotnREST and OSC inputs. For iotnREST, this is the URL sent to the remote device. For OSC, this is the OSC message that AnalogIn will listen for (e.g. “/slider/1” will listen for the message from iPhone app OSCemote’s first slider).

Connecting Servos

Servos typically have a 3pin connector with the following wires:
  • Ground – Black or Brown
  • Power – Red or Orange (always in the middle)
  • Signal – Yellow, White or Orange
Connect the Ground and Power wires to their respective connections on the microcontroller. Connect the Signal wire to the appropriate port on the microcontroller as specified in the ServoOutput controllerPort parameter. For Arduino, this should be one of the digital output pins, starting at 2 or higher. For the Make, there are specific ports with 3pin connectors just for servos.

Using an external power supply

The Arduino is only able to power small servos reliably because servos require a lot of power. So a better approach is to use a separate power supply for the servo. To do this, connect the power supply (4.8-6 volts) to the servo Ground and Power, but you must also connect the Arduino Ground to the Ground on the external power supply. Connect the servo Signal as usual.
The below diagram (made with Fritzing) shows how two servos can be connected to the Arduino using a battery pack with four AA batteries (makes about 6V) as an external power supply.

Mechanical systems for Servos

To make projects with servos you often need to make a mechanical connection to something else that the servo moves. Here are some links for commonly used attachments:

servo_mounted_in_channel_with_hub_and_linkage__and_beam

Code Interface

connectWidget()

Causes the widget to connect to the controller, the same result as using the connect button.

myServoOut.connectWidget();

disconnectWidget()

Causes the widget to connect to the controller, the same result as using the connect button.

myServoOut.disconnectWidget();

Last modified July 6th, 2014