Summary of Controlling a Servo with a PICAXE and an IR Sensor
This article explains building a finger-tracking device using a PICAXE microcontroller, IR LEDs, and an IR phototransistor. The system detects reflected infrared light to determine stimulus position, allowing the PICAXE to control a servo motor's rotation accordingly.
Parts used in the Finger-Tracking Device:
- PICAXE microcontroller
- Infrared (IR) LEDs
- IR phototransistors
- Servo motor (Tower-Pro MG996R)
- BASIC programming language environment
Related Information
- Servo Motor Control with an Arduino
- Servo Control with Arduino Through MATLAB
- Servo Control via USB with the SAM4S Xplained Pro
- Control a Servo from Your PC with the Atmel SAM4S
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.
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.
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
-
What is a PICAXE?
PICAXEs are PIC microcontrollers preloaded with bootstrap code that allows programming in BASIC language. -
How does the project detect movement?
The circuit uses common IR LEDs to emit light and an IR phototransistor to detect reflected IR light intensity. -
Can a PICAXE convert analog signals?
Yes, the specially programmed PICAXE converts the analog voltage from the phototransistor into a digital format for comparison. -
What voltage range does the MG996R servo operate on?
The MG996R servo operates on a voltage range of 4.8V to 7.2V. -
How much current can the MG996R draw?
The servo can draw from 500 mA to almost a full ampere depending upon its load. -
What is the output shaft range of the MG996R?
The output shaft covers a range of 120 degrees, which is 60 degrees each side of center. -
What components make up a servomotor?
A servomotor consists of an electric motor with an accessible output shaft, a mechanism to determine rotary position, and electronic circuitry.

