Servos are used in most radio controlled cars and planes to control the steering mechanism. They are accurate devices that always rotate the same amount for a given signal, and so are ideal for use in many automated machines.

A typical servo has just three connection wires, normally red, black and white (or yellow). The red wire is the 5V supply, the black wire is the 0V supply, and the white (or yellow) wire is for the positioning signal.

The positioning signal is a pulse between 0.75 and 2.25 milliseconds (ms) long, repeated about every 18ms (so there are roughly 50 pulses per second). With a 0.75ms pulse the servo moves to one end of its range, and with a 2.25ms pulse the servo moves to the other. Therefore, with a 1.5ms pulse, the servo will move to the central position. If the pulses are stopped the servo will move freely to any position.

Related Commands:

Print Page




Move a servo

This program will slowly move a servo connected to output pin B.1 from one position to another, jump back to its start postion and repeat.

Code Example:
main:	servo B.1, 80		; Set the servo to its starting position
	pause 500		; Stay at the start position for a while

	for b0 = 80 to 200	; Move the servo from position 80 to 200
	  servopos B.1, b0	;   Set the new position
	  pause 20		;   Wait a while
	next b0			; Continue until at position desired

	goto main		; Repeat from start position
Copy Code Submit an Example

Create Module

The servo connection wire can be connected directly to the servo create module.

Bill of Materials

9g miniature servo GBX013 1 Buy Now
3-way 0.1" header CON035 1 Buy Now


No Image Selected

Submit Your Own Code!

You must be logged in to submit code examples. Login now.


  • Login to leave a comment.