Category: Robotics

Stepper motors are not like simple DC motors and cannot be driven by providing just DC voltage.Driver circuit & a microcontroller  are needed to control the speed & direction of a stepper.

With a stepper motor you can “step” exactly a given angle. Further the stepper motor has the   advantage of having a holding torque.Steppers are able hold their position when they are not moving.

Stepper motors are available in two varieties : unipolar or bipolar.

Bipolar motors are the strongest type of stepper motor and usually have four leads. They have two sets of electromagnetic coils internally, and stepping is achieved by changing the direction of current within those coils.

Unipolar motors, identifiable by having 5,6 or even 8 wires, also have two coils, but each one has a center tap. Unipolar motors can step without having to reverse the direction of current in the coils, making the electronics simpler. However, because the center tap is used to energize only half of each coil at a time they typically have less torque than bipolar.

Unipolar motors typically have two coils per phase, one for each direction of magnetic field.

Bipolar motors typically have one coil per phase, and current flows in both directions through this coil. Thus,  the bipolar motor will be able to produce twice as much torque, since at any given time, the unipolar motor is only using half of its windings







BIPOLAR steppers generally have 4 wires & are best driven by a H BRIDGE IC like L293 (500 ma current) or L298 ( 2 amps).

One thing you’ve to keep in mind is that when using a stepper driver, you are powering the driver, not the motor. The driver will take over powering the motor for you.

To find out the phase of coils in a 6 wire Stepper , we shall make use of a simple Multi meter.

Put one lead of Meter on any of the 6 wires of Stepper & look out for continuity with other 5 wires.You can find 2 sets of 3 wires having continuity .



As seen in above screenshot , keeping one end of meter probe on any of the wires you can identify the continuous wires.The meter will show some resistance value if there is a continuity.

Identify the set of 3 wires & make a knot to separate the 2 set of 3 wires.




Now you can easily identify the center tap of the 3 wires.With respect to the center tap wire the other ends show an equal resistance value.

Here the green wire of one set of 3 wires is the center wire & it shows exactly half the value of total resistance with other 2 wires of the coil .

On the other set of 3 wires , the black wire is the center one.

To use this motor as a Bipolar one , simply leave out the center wires (here it is the green & the black ones).

Now each phase of coil has only 2 wires , which can be easily driven by a H bridge IC L298.





Leave out the 2 center tap wires & then connect the 2 sets of wires to M1,M2  &  M3,M4 of the L298 board.M1/M2 is for first coil & M3/M4 for the second coil.




We shall make use of an Arduino UNO board to control the Stepper .

An external power supply of 12v/1Amp is required for the L298 board.If you try to power the L298 from Arduino it will cause damage to  your Arduino.

Following is the code to be uploaded on to Arduino. Before uploading , we shall understand the code so that the connections are made accordingly between Arduino & L298 board.


#include <Stepper.h>

int clockwise= 2;
int anticlockwise= 3;
int steps =200;
int enable=8;
Stepper motor(steps, 10,11,12,13);

void setup() {

void loop() {
int Speed = analogRead(A0);
int RPM = map(Speed, 0, 1023, 0, 100);
int forward = digitalRead(clockwise);
int reverse = digitalRead(anticlockwise);
if(forward == 1 && reverse == 0 && RPM > 5){
if(reverse == 1 && forward == 0  && RPM > 5){
Serial.println(“Speed of motor is “);
Serial.println(RPM );


Initially we’re including the Stepper library  Stepper.h.

An instance called “motor” is initiated for the Stepper class, with Steps = 200 (generally step angle of Stepper is 1.8 deg.For a full rotation of 360 deg we need 200 steps 200 x 1.8  = 360).

Pins 10,11 of Arduino assigned to control coil 1 & connected to IN1,IN2 of L298.

Pins 12,13 of Arduino assigned to control coil 2 & connected to IN3,IN4 of L298 board.

Two push switches are used to control the direction of Stepper.One switch is connected to pin 2 (clockwise) & the other one to pin3 (anticlockwise).The connections are made so that when a switch is pressed , a HIGH (5v) is applied to Arduino pins 2 or 3 accordingly.

The speed of Stepper is controlled by a 10k potentiometer which is connected to A0 of Arduino.The analog value of potentiometer is mapped to a value between 0 and 100 & assigned to a variable RPM.

According to the conditions of Switches (clockwise or Anticlockwise)  & RPM set by the potentiometer the Stepper will move accordingly.


Important point to take note:

Pin 8 of Arduino is assigned to ENABLE ,which is connected to both EN1,EN2 of L298 board.While starting the loop Enable is made LOW & it’s made HIGH only when a switch is pressed.This ensures that the Stepper is not enabled at idle conditions.If you’re not controlling the ENABLE pin , the L298 IC will heat up even when the Stepper motor is not running.This will damage the L298 IC and the Stepper motor , as well.




Connection Details

L298 BOARD              Arduino Board

EN1 & EN2   —–>    8

IN1              —–>   10

IN2             —–>     11

IN3             —–>     12

IN4              —–>     13

M1/M2  —  2 wires of first coil of stepper.

M3/M4  —  2wires of second coil of stepper.

CW switch     —–>    2 ,  one end of switch connected to +5v, other end grounded through 10k .

CCW switch     —–>   3

12V/1A adapter connected to GND/12V of L298

Both GND pins of L298 & Arduino made common

10k Potentiometer – center pin to A0 , top pin to +5v & bottom pin to GND


Watch this support Video :


BIPOLAR Stepper control with HBRIDGE


cooltext753793315    cooltext753790696


Speech recognition is commonly used  for controlling appliances, toys, tools and computers. It is used in Robotics to control motors according to voice commands.

The heart of the circuit is the HM2007 speech recognition IC. HM2007 is made by HUALON Microelectronics Corporation(Taiwan) .

The IC can recognize 20 words, each word a length of 1.92 seconds.




Speech samples are acquired by a Microphone on board.HM2007 analyzes the analog signal received compares with the data stored in external RAM & finally outputs a corresponding 8 bit Data.This 8 bit data can be directly connected to a port of Microcontroller for further action.

An 8 kB external RAM is needed to store data.As the RAM is volatile , a 3v button battery is used to backup stored data.The 8 bit data is passed through an octal latch IC 74HC573.

To display the command numbers 2 common cathode 7 segment displays are provided.This is driven by a BCD to 7 segment decoder/driver IC CD4511.

The board requires 5v DC supply. A 12v adapter can be used as a power source, as the board has inbuilt 5v regulator with heat sink.

The HM 2007 IC requires initial configuration or training of words, which is performed using a 4 x 3 Matrix Keypad. In the training process user trains the IC by speaking words into the microphone and

assigning a particular value for that word. For example a world “left” can be assigned a value 01.This can then be later connected to a microcontroller for further functions.

Words  can be assigned from 01 to 20.


Training Words for Recognition:

Before starting the training process we can erase the previous memory.

Press 99 & then press the CLEAR button.

The display will scroll from 01 to 20 erasing all the memory

To train a word

Press “01” on the keypad.Display will show “01” and the READY LED will turn off.Now press the TRAIN key ( the LED will turn on) & HM2007 goes to  training mode, for word one.

Say the target word into the onboard microphone (near LED) clearly. The READY LED should blink momentarily indicating the acceptance of word.

If the LED did not flash, start again by pressing “1” and then “TRAIN” key.

You may continue training new words in the circuit. Press “02” then TRAIN key to train the second word and so on. The circuit will accept and recognize up to 20 words (numbers 01 through 20).

It is not necessary to train all word spaces. If you only require 5 target words that’s all you NEED TO TRAIN.

If the system has to work under noisy environments, background noise may corrupt the original data and leads to malfunctioning.Take care to avoid using this board in Noisy places.

Error codes generally displayed


55 = word too long

66 = word too short

77 = word no match


Image 1


Let us test the board by connecting to a Motor through a motor driver board L293.This L293 can drive 2 motors at a time.For demo we’re using one part of the IC.

Functioning of L293 can be understood from this post.

EN1 of L293 should be made HIGH and according to logic levels at IN1 & IN2 the motor will rotate to Right or Left or Stop.

DSC01106            HM2007_MOTOR



HM2007 Outputs an  8 bit Data buffered by 74HC573 IC & available as two 4 bits.

D0 to D3 represent one digit & the second one by D4 to D7

We shall connect

EN1 of L293 TO  D4

IN1 of L293 TO  D3

IN2 of L293 TO  D0

Provide a separate 12v DC power source to L293 board.Do not forget to make common the GND of L293 BOARD and that of HM2007 board.

Check out the table below to see how to achieve a number for a Word.

Here we’ve assigned decimal  11 for RIGHT  ,  18 for LEFT  &  08 for STOP.



To rotate the motor to RIGHT we assign Decimal value  11 .To rotate LEFT a decimal value of 18 is assigned.

To stop the motor decimal 08 is assigned.The calculation of arriving at these values are shown in table above.


Train the HM2007 board by pressing 11 & then TRAIN key for the word RIGHT.

Then press 18 & TRAIN for the word LEFT.

Finally 08 & TRAIN for the word STOP.

Now speak the word RIGHT to see the motor rotate Rightwards, LEFT to notice the motor rotating leftwards & STOP will apply brake to motor.Corresponding Digit will be displayed on the 7 SEGMENT Displays.



Motor Control by Voice Recognition


cooltext753793315  cooltext753790696

In this post we shall see how to make a Line Follower Robot using the multipurpose iBot designed by Robosapiens .This kit is an excellent design , easy to assemble & learn for beginners in Robotics.

The kit is built on AVR ATMEGA8 development board.As the AVR IC is pre-loaded with Boot Loader there is no need of an external programmer. Hex files can be loaded on to the IC using HIDBOOTFLASH application.

The AVR  Board can work on 6V to 15V DC supply. The control circuit is basically L293D based Dual H – Bridge Motor Driver Circuit with Inverting Buffer which is used for the locomotion of the robot. The motor driver circuit used, intakes digital inputs to make motors running.

The kit is provided with two IR based Digital proximity Sensors that is used as a line sensor. The sensor that is being used is highly flexible and versatile. The sensors can be used as an edge sensor , obstacle sensor , color sensor (black / white) , light sensor etc. Sound Sensor can also be interfaced for making Robots like clap to move,clap to stop



robot1         90

Mechanical Assembly Video :

Line Follower Robot–Mechanical Assembly

Now that the mechanical assembly part is over , let us see how to load the hex files on to the AVR IC.

We shall make use of HIDBOOTFLASH application for this purpose.

Download the application from–files/project:hidbootflash/

Unzip the downloaded file.It is a small standalone exe file  which needs no installation.

Connect the USB cable from Robot to PC & click on Find Device.

Image 1


If the hardware is detected you get the next screen.

Check mark “Reboot AVR” & click on  “Open .hex file”.

Browse to the location where you’ve stored the hex files .Select the required .Hex file to be loaded & click on “Flash Device “

Image 3

If the file is loaded on to the IC , the LEDs PB1 & PB4 glows on the demo board


Image 4

Now remove the USB cable & switch on the power switch to see the Robot working.

Here is the sample C code for a simple Line Follower Robot.This C code can be compiled to a .hex file using WINAVR or  ATMELSTUDIO.


// Project name : line follower
// Designed By  : ROBOMART
Connection settings of Kit


BOOTLooder Condition Check—–>PC5(f 0 bootler section else program execution
section of Flash memory)
Crystal Oscillator————–>PB6 and PB7
VB=Battery Supply
VCC=Regulated 5V+


void main()
DDRC=0b0000000;   //set PORTC as input port
DDRB=0b00011110;  //PB1, PB2, PB3, PB4 as output port
int ls=0, rs=0;   // define & initialize ls, rs integer as 0 to acquire the left sensor status in ls and right sensor status in rs

while(1)          // create infinite loop
ls=(PINC&0b0000001);   //acquire only left sensor status connected at PC0
rs=(PINC&0b0001000);   // acquire only right sensor status connected at PC3

if((ls==0b0000000)&(rs==0b0000000)) //check sensor status for both sensor OFF
PORTB=0b00000000;  //stop
ls=0;              //set sensor status off
rs=0;              //set sensor status off

if((ls == 0b0000001)&(rs == 0b0000000))  //check sensor status for left sensor=ON and right sensor=OFF


PORTB=0b00010000;    //turn right
ls=0;                //set sensor status off
rs=0;                //set sensor status off

if((ls == 0b0000000)&(rs == 0b0001000))  //check sensor status for left sensor=OFF and right sensor=ON


PORTB=0b00000010;   //turn left
ls=0;               //set sensor status off
rs=0;               //set sensor status off
if((ls==0b0000001)&(rs==0b0001000)) //check sensor status for both sensor ON
PORTB=0b00010010;  //move forward
ls=0;              //set sensor status off
rs=0;              //set sensor status off



Video 2 : Loading the Hex file

cooltext753793315     cooltext753795865