Controlling a Servo with a PICAXE and an IR Sensor

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
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

Quick Solutions to Questions related to Finger-Tracking Device:

  • 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.

About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:
LinkedinTwitter