Controlling a Servo with a PICAXE and an IR Sensor

Learn how to combine a PICAXE, IR sensors, and a servo motor to create a device that responds to a moving stimulus. Spoilers: I hook it up to eyeballs that can follow a finger.

Related Information


What’s a PICAXE?

PICAXEs are PIC microcontrollers that have been preloaded with a bootstrap code that allows programming in BASIC language. All About Circuits provides a series of articles that serve as a guide to choosing and using any of the chips in the PICAXE family. This article will provide an excellent starting point and will lead you to other articles in the series.Controlling a Servo with a PICAXE and an IR Sensor

Project Overview

This project consists of building a circuit using common IR (infrared) LEDs to produce IR emissions and an IR phototransistor to detect reflected IR light. The voltage from the phototransistors varies with the intensity of the IR light received. A specially programmed PICAXE microcontroller converts this analog voltage to a digital format and stores it for comparison with the output from other IR phototransistors.

Based on the relative levels of the IR light, the PICAXE signals a servo motor to rotate to a predetermined position. Thus, reflected IR light can be used to control physical movements.


What’s a Servo?

Servos, or more specifically servomotors, are electromechanical devices that consist of (1) an electric motor with an accessible output shaft, (2) a mechanism to determine the rotary position of the output shaft, and (3) electronic circuitry to receive control signals and position the output shaft accordingly.

One of the most familiar uses of small servos is to move the throttle and control surfaces of RC (radio control) airplanes. Servos are available in a variety of sizes, shapes, and capabilities. A servo suitable for use in this project is the Tower-Pro MG996R, two of which are shown in the photo below.Motor Controlling a Servo with a PICAXE and an IR Sensor

The MG996R servo operates on 4.8V to 7.2V, and can draw from 500 mA to almost a full ampere depending upon its load. The output shaft covers a range of 120 degrees (60 degrees each side of center.) For a more complete description, download and read the datasheet. A little on-line research will produce all the information you can imagine about servomotors.

For more detail: Controlling a Servo with a PICAXE and an IR Sensor

Leave a Comment

= 4 + 6

Read previous post:
Graphene Patterned at Room Temp
Graphene Patterned at Room Temp

This room temperature method, instead takes the easily grown graphene-on-copper and in a single-step (they claim) etch and transfer the...

Scroll to top