Hello Readers, welcome to my Blog - A Blog For Bloggers By A Blogger. I'm Arun, an entrepreneur Blogger from India.

Accelerometer based Hand Gesture Controlled Robot with ATmega32

12616
Mark as Favourite

In many application of controlling robotic gadget it becomes quite hard and complicated when there comes the part of controlling it with remote or many different switches. Mostly in military application, industrial robotics, construction vehicles in civil side, medical application for surgery. In this field it is quite complicated to control the robot or particular machine with remote or switches, sometime the operator may get confused in the switches and button itself, so a new concept is introduced to control the machine with the movement of hand which will simultaneously control the movement of robot.

In this project, we will learn How to design an accelerometer based hand gesture controlled robot with AVR ATmega32 microcontroller. Here, we will use our hand gestures as input signals to drive the robot in different direction and we will display the direction of movement of the robot in a 16X2 alphanumeric LCD. In our case, hand gestures mean tilt of hand in different direction. To detect different hand gestures, we will use the ADX335 accelerometer sensor. The sensor will be attached to our hand with some material or through a hand glove. The three output signals of accelerometer sensor are analog in nature and it cannot be processed directly by ATmega32 microcontroller. For this, we will use the ADC of the ATmega32 microcontroller to convert the analog signals to digital values. After converting the analog signals of accelerometer sensor to digital values, the ATmega32 microcontroller will process the digital values to find different gestures of the hand. Once the hand gesture is known, the ATmega32 microcontroller will send the required signal to the DC motor driver (L293D) of the robot to drive the robot in the desired direction. Also, the microcontroller will display the direction of movement of the robot in a 16X2 alphanumeric LCD. The control hand gestures for the robot are forward tilt, backward tilt, left tilt, right tilt and no tilt to drive the robot in forward, backward, left, right direction and to stop it respectively. Now, tilt your hand in different direction and drive your robot as you want.

Control Hand Gestures

Robot Direction

Forward Tilt

Forward

Left Tilt

Left

Right Tilt

Right

Backward Tilt

Backward

no Tilt

Stop

Softwares Required

Hardwares Required

Name / Unit Price Quantity Total Price
AVR Trainer Board-100 with ATmega32
Rs. 730.00
1pc
Rs.730.00
AVR USB Programmer
Rs. 350.00
1pc
Rs.350.00
12V, 1A DC SMPS Adaptor
Rs. 130.00
1pc
Rs.130.00
RG1602A 16X2 Alphanumeric LCD Green
Rs. 150.00
1pc
Rs.150.00
DC Motor Driver
Rs. 200.00
1pc
Rs.200.00
Robot V 4.1
Rs. 330.00
1pc
Rs.330.00
3-axis Accelerometer Sensor
Rs. 350.00
1pc
Rs.350.00
1 to 1 Connector-Female to Female
Rs. 4.00
4pc
Rs.16.00
5 to 5 Connector-Female to Female-1 Meter
Rs. 60.00
1pc
Rs.60.00
10 to 10 FRC Female to Female Connector
Rs. 15.00
3pc
Rs.45.00
TOTAL Rs.2361.00

Circuit Diagram

Accelerometer-based-Hand-Gesture-Controlled-Robot-with-AVR-ATmega32-Microcontroller-Circuit-Diagram-1024x633

C Program

Fullscreen
 

 //**************************************************************//
//System Clock                          :1MHz
//Software                                 :AVR Studio 4
//LCD Data Interfacing             :8-Bit
//**************************************************************//

#include<avr/io.h>
/*Includes io.h header file where all the Input/Output Registers and its Bits are defined for all AVR microcontrollers*/

#define           F_CPU           1000000
/*Defines a macro for the delay.h header file. F_CPU is the microcontroller frequency value for the delay.h header file. Default value of F_CPU in delay.h header file is 1000000(1MHz)*/

#include<util/delay.h>
/*Includes delay.h header file which defines two functions, _delay_ms (millisecond delay) and _delay_us (microsecond delay)*/

#define           LCD_DATA_PORT           PORTB
/*Defines a macro for the lcd.h header File. LCD_DATA_PORT is the microcontroller PORT Register to which the data pins of the LCD are connected. Default PORT Register for data pins in lcd.h header file is PORTA*/

#define           LCD_CONT_PORT           PORTD
/*Defines a macro for the lcd.h header File. LCD_CONT_PORT is the microcontroller PORT Register to which the control pins of the LCD are connected. Default PORT Register for control pins in lcd.h header file is PORTB*/

#define           LCD_RS           PD0
/*Defines a macro for the lcd.h header file. LCD_RS is the microcontroller Port pin to which the RS pin of the LCD is connected. Default Port pin for RS pin in lcd.h header file is PB0*/

#define           LCD_RW           PD1
/*Defines a macro for the lcd.h header file. LCD_RW is the microcontroller Port pin to which the RW pin of the LCD is connected. Default Port pin for RW pin in lcd.h header file is PB1*/

#define           LCD_EN           PD2
/*Defines a macro for the lcd.h header file. LCD_EN is the microcontroller Port pin to which the EN pin of the LCD is connected. Default Port pin for EN pin in lcd.h header file is PB2*/

#include<avr/lcd.h>
/*Includes lcd.h header file which defines different functions for all Alphanumeric LCD(8-Bit Interfacing Method). LCD header file version is 1.1*/

#include<avr/adc.h>
/*Includes adc.h header file which defines different functions for Analog to Digital Converter. ADC header file version is 1.1*/

#include<avr/adxl335.h>
/*Includes adxl335.h header file which defines different functions for ADXL335 Accelerometer Sensor. ADXL335 header file version is 1.1*/

#define           X_MIN           310
/*Defines the lower threshold for the x-axis value of adxl335*/

#define           X_MAX           390
/*Defines the upper threshold for the x-axis value of adxl335*/

#define           Y_MIN           310
/*Defines the lower threshold for the y-axis value of adxl335*/

#define           Y_MAX           390
/*Defines the upper threshold for the y-axis value of adxl335*/

int main(void)
{

DDRB=0xff;
/*All the 8 pins of PortB are declared output (data pins of LCD are connected)*/

DDRD=0x07;
/*PD0, PD1 and PD2 pins of PortD are declared output (control pins of LCD are connected)*/

DDRC=0x0f;
/*PC0,PC1,PC2 and PC3 pins of PortC are declared output ( i/p1,i/p2,i/p3,i/p4 pins of DC Motor Driver are connected )*/

int x_axis,y_axis;
/*Variable declarations*/

adc_init();
/*ADC initialization*/

lcd_init();
/*LCD initialization*/

lcd_string_write(“ABLab Solutions”);
/*String display in 1st row of LCD*/

lcd_command_write(0xc0);
/*Cursor moves to 2nd row 1st column of LCD*/

lcd_string_write(“www.ablab.in”);
/*String display in 2nd row of LCD*/

_delay_ms(500);
_delay_ms(500);
_delay_ms(500);
_delay_ms(500);
/*Display stays for 2 second*/

lcd_command_write(0x01);
/*Clear screen*/

lcd_string_write(“Tilt your Hand:”);
/*String display in 1st row of LCD*/

lcd_command_write(0xc0);
/*Cursor moves to 2nd row 1st column of LCD*/

/*Start of infinite loop*/
while(1)
{

x_axis=read_adxl335_x_value(0);
/*Reading x-axis value of Accelerometer Sensor*/

y_axis=read_adxl335_x_value(1);
/*Reading y-axis value of Accelerometer Sensor*/

lcd_command_write(0xc0);
/*Cursor moves to 2nd row 1st column of LCD*/

/*Checking the tilt of the Hand(sensor) to move the robot in different direction*/
if(x_axis>X_MAX)
{

PORTC=0x0A;
/*Robot will move forward direction*/

lcd_string_write(“Moving Forward “);
/*String display in 2nd row of LCD*/

}
else if(x_axis<X_MIN)
{

PORTC=0x05;
/*Robot will move in backward direction*/

lcd_string_write(“Moving Backward”);
/*String display in 2nd row of LCD*/

}
else if(y_axis>Y_MAX)
{

PORTC=0x08;
/*Robot will move in right direction*/

lcd_string_write(“Moving Right “);
/*String display in 2nd row of LCD*/

}
else if(y_axis<Y_MIN)
{

PORTC=0x02;
/*Robot will move in left direction*/

lcd_string_write(“Moving Left “);
/*String display in 2nd row of LCD*/

}
else
{

PORTC=0x0F;
/*Robot will stop*/

lcd_string_write(“Stopped “);
/*String display in 2nd row of LCD*/

}

}

}

 //**************************************************************//
//System Clock                          :1MHz
//Software                                 :AVR Studio 4
//**************************************************************//

#include<avr/io.h>
/*Includes io.h header file where all the Input/Output Registers and its Bits are defined for all AVR microcontrollers*/

#define           F_CPU           1000000
/*Defines a macro for the delay.h header file. F_CPU is the microcontroller frequency value for the delay.h header file. Default value of F_CPU in delay.h header file is 1000000(1MHz)*/

#include<util/delay.h>
/*Includes delay.h header file which defines two functions, _delay_ms (millisecond delay) and _delay_us (microsecond delay)*/

#include<avr/adc.h>
/*Includes adc.h header file which defines different functions for Analog to Digital Converter. ADC header file version is 1.1*/

#define           REF1           615
/*Defines a macro for the Upper Reference value for the sensor*/

#define           REF2           300
/*Defines a macro for the lower Reference value for the sensor*/

int main(void)
{

DDRB=0x0f;
/*PB0,PB1,PB2 and PB3 pins of PortB are declared output ( i/p1,i/p2,i/p3,i/p4 pins of DC Motor Driver are connected )*/

int sensor_value;
/*Variable declarations*/

adc_init();
/*ADC initialization*/

/*Start of infinite loop*/
while(1)
{

sensor_value=read_adc_channel(0);
/*Reading the IR sensor value*/

/*Checking the sensor values with the reference values*/
if((sensor_value < REF1) && (sensor_value > REF2))
{

PORTB=0x0a;
/*Robot will move in forward direction*/

}
else
{

PORTB=0x0f;
/*Robot will stop*/

}

}

}
/*End of Program*/

  

 //**************************************************************//
//System Clock                          :1MHz
//Software                                 :AVR Studio 4
//LCD Data Interfacing             :8-Bit
//**************************************************************//

#include<avr/io.h>
/*Includes io.h header file where all the Input/Output Registers and its Bits are defined for all AVR microcontrollers*/

#define           F_CPU           1000000
/*Defines a macro for the delay.h header file. F_CPU is the microcontroller frequency value for the delay.h header file. Default value of F_CPU in delay.h header file is 1000000(1MHz)*/

#include<util/delay.h>
/*Includes delay.h header file which defines two functions, _delay_ms (millisecond delay) and _delay_us (microsecond delay)*/

#define           LCD_DATA_PORT           PORTB
/*Defines a macro for the lcd.h header File. LCD_DATA_PORT is the microcontroller PORT Register to which the data pins of the LCD are connected. Default PORT Register for data pins in lcd.h header file is PORTA*/

#define           LCD_CONT_PORT           PORTD
/*Defines a macro for the lcd.h header File. LCD_CONT_PORT is the microcontroller PORT Register to which the control pins of the LCD are connected. Default PORT Register for control pins in lcd.h header file is PORTB*/

#define           LCD_RS           PD0
/*Defines a macro for the lcd.h header file. LCD_RS is the microcontroller Port pin to which the RS pin of the LCD is connected. Default Port pin for RS pin in lcd.h header file is PB0*/

#define           LCD_RW           PD1
/*Defines a macro for the lcd.h header file. LCD_RW is the microcontroller Port pin to which the RW pin of the LCD is connected. Default Port pin for RW pin in lcd.h header file is PB1*/

#define           LCD_EN           PD2
/*Defines a macro for the lcd.h header file. LCD_EN is the microcontroller Port pin to which the EN pin of the LCD is connected. Default Port pin for EN pin in lcd.h header file is PB2*/

#include<avr/lcd.h>
/*Includes lcd.h header file which defines different functions for all Alphanumeric LCD(8-Bit Interfacing Method). LCD header file version is 1.1*/

#include<avr/adc.h>
/*Includes adc.h header file which defines different functions for Analog to Digital Converter. ADC header file version is 1.1*/

#include<avr/adxl335.h>
/*Includes adxl335.h header file which defines different functions for ADXL335 Accelerometer Sensor. ADXL335 header file version is 1.1*/

#define           X_MIN           310
/*Defines the lower threshold for the x-axis value of adxl335*/

#define           X_MAX           390
/*Defines the upper threshold for the x-axis value of adxl335*/

#define           Y_MIN           310
/*Defines the lower threshold for the y-axis value of adxl335*/

#define           Y_MAX           390
/*Defines the upper threshold for the y-axis value of adxl335*/

int main(void)
{

DDRB=0xff;
/*All the 8 pins of PortB are declared output (data pins of LCD are connected)*/

DDRD=0x07;
/*PD0, PD1 and PD2 pins of PortD are declared output (control pins of LCD are connected)*/

DDRC=0x0f;
/*PC0,PC1,PC2 and PC3 pins of PortC are declared output ( i/p1,i/p2,i/p3,i/p4 pins of DC Motor Driver are connected )*/

int x_axis,y_axis;
/*Variable declarations*/

adc_init();
/*ADC initialization*/

lcd_init();
/*LCD initialization*/

lcd_string_write(“ABLab Solutions”);
/*String display in 1st row of LCD*/

lcd_command_write(0xc0);
/*Cursor moves to 2nd row 1st column of LCD*/

lcd_string_write(“www.ablab.in”);
/*String display in 2nd row of LCD*/

_delay_ms(500);
_delay_ms(500);
_delay_ms(500);
_delay_ms(500);
/*Display stays for 2 second*/

lcd_command_write(0x01);
/*Clear screen*/

lcd_string_write(“Tilt your Hand:”);
/*String display in 1st row of LCD*/

lcd_command_write(0xc0);
/*Cursor moves to 2nd row 1st column of LCD*/

/*Start of infinite loop*/
while(1)
{

x_axis=read_adxl335_x_value(0);
/*Reading x-axis value of Accelerometer Sensor*/

y_axis=read_adxl335_x_value(1);
/*Reading y-axis value of Accelerometer Sensor*/

lcd_command_write(0xc0);
/*Cursor moves to 2nd row 1st column of LCD*/

/*Checking the tilt of the Hand(sensor) to move the robot in different direction*/
if(x_axis>X_MAX)
{

PORTC=0x0A;
/*Robot will move forward direction*/

lcd_string_write(“Moving Forward “);
/*String display in 2nd row of LCD*/

}
else if(x_axis<X_MIN)
{

PORTC=0x05;
/*Robot will move in backward direction*/

lcd_string_write(“Moving Backward”);
/*String display in 2nd row of LCD*/

}
else if(y_axis>Y_MAX)
{

PORTC=0x08;
/*Robot will move in right direction*/

lcd_string_write(“Moving Right “);
/*String display in 2nd row of LCD*/

}
else if(y_axis<Y_MIN)
{

PORTC=0x02;
/*Robot will move in left direction*/

lcd_string_write(“Moving Left “);
/*String display in 2nd row of LCD*/

}
else
{

PORTC=0x0F;
/*Robot will stop*/

lcd_string_write(“Stopped “);
/*String display in 2nd row of LCD*/

}

}

}

 //**************************************************************//
//System Clock                          :1MHz
//Software                                 :AVR Studio 4
//**************************************************************//

#include<avr/io.h>
/*Includes io.h header file where all the Input/Output Registers and its Bits are defined for all AVR microcontrollers*/

#define           F_CPU           1000000
/*Defines a macro for the delay.h header file. F_CPU is the microcontroller frequency value for the delay.h header file. Default value of F_CPU in delay.h header file is 1000000(1MHz)*/

#include<util/delay.h>
/*Includes delay.h header file which defines two functions, _delay_ms (millisecond delay) and _delay_us (microsecond delay)*/

#include<avr/adc.h>
/*Includes adc.h header file which defines different functions for Analog to Digital Converter. ADC header file version is 1.1*/

#define           REF1           615
/*Defines a macro for the Upper Reference value for the sensor*/

#define           REF2           300
/*Defines a macro for the lower Reference value for the sensor*/

int main(void)
{

DDRB=0x0f;
/*PB0,PB1,PB2 and PB3 pins of PortB are declared output ( i/p1,i/p2,i/p3,i/p4 pins of DC Motor Driver are connected )*/

int sensor_value;
/*Variable declarations*/

adc_init();
/*ADC initialization*/

/*Start of infinite loop*/
while(1)
{

sensor_value=read_adc_channel(0);
/*Reading the IR sensor value*/

/*Checking the sensor values with the reference values*/
if((sensor_value < REF1) && (sensor_value > REF2))
{

PORTB=0x0a;
/*Robot will move in forward direction*/

}
else
{

PORTB=0x0f;
/*Robot will stop*/

}

}

}
/*End of Program*/

Connection Guide

The step-by-step connection guide for Accelerometer based Hand Gesture Controlled Robot with ATmega32 is as follows:

  • Insert the DC Pin of 12V, 1A DC Adapter to the DC Socket of AVR Trainer Board-100.

    Steps - 1 ( 0f 13 )

  • Connect PortB header with LCD data header in AVR Trainer Board-100 with a 10 to 10 FRC Female Connector.

    Steps - 2 ( 0f 13 )

  • Connect RS, RW & EN pins of LCD control header with PD0, PD1 & PD2 pins of PortD header respectively in AVR Trainer Board-100 with 1 to 1 Connectors.

    Steps - 3 ( 0f 13 )

  • Connect the 16X2 Alphanumeric LCD to the LCD header of AVR Trainer Board-100.

    Steps - 4 ( 0f 13 )

  • Connect PortC header of AVR Trainer Board-100 with Input header of DC Motor Driver with a 10 to 10 FRC Female Connector.

    Steps - 5 ( 0f 13 )

  • Connect the 12V pin of PWM & Motor Voltage header of DC Motor Driver with the 12V header of AVR Trainer Board-100 with a 1 to 1 Connector.

    Steps - 6 ( 0f 13 )

  • Connect the Robot connector to the Output header of the DC Motor Driver.

    Steps - 7 ( 0f 13 )

  • Switch off the Mode Switch of DC Motor Driver.

    Steps - 8 ( 0f 13 )

  • Connect the X, Y, Z, VCC and GND pins of Accelerometer Sensor header of 3-axis Accelerometer Sensor with PA0, PA1, PA2, VCC and GND pin of PortA header of AVR Trainer Board-100 with a 5 to 5 Connector.

    Steps - 9 ( 0f 13 )

  • Connect the ISP header of AVR Trainer Board-100 with AVR USB Programmer header of AVR USB Programmer with a 10 to 10 FRC Female Connector.

    Steps - 10 ( 0f 13 )

  • Connect the AVR USB Programmer to the PC/Laptop's USB Port directly or with the help of USB AM-AF Cable.

    Steps - 11 ( 0f 13 )

  • Switch on the power with the help of Power Switch of AVR Trainer Board-100.

    Steps - 12 ( 0f 13 )

  • Download Accelerometer based Hand Gesture Controlled Robot with ATmega32 Hex file to AVR Trainer Board-100 with the help of SinaProg Hex downloader and AVR USB Programmer.

    Steps - 13 ( 0f 13 )

  • Insert the DC Pin of 12V, 1A DC Adapter to the DC Socket of AVR Trainer Board-100.

    Steps - 1 ( 0f 13 )

  • Connect PortB header with LCD data header in AVR Trainer Board-100 with a 10 to 10 FRC Female Connector.

    Steps - 2 ( 0f 13 )

  • Connect RS, RW & EN pins of LCD control header with PD0, PD1 & PD2 pins of PortD header respectively in AVR Trainer Board-100 with 1 to 1 Connectors.

    Steps - 3 ( 0f 13 )

  • Connect the 16X2 Alphanumeric LCD to the LCD header of AVR Trainer Board-100.

    Steps - 4 ( 0f 13 )

  • Connect PortC header of AVR Trainer Board-100 with Input header of DC Motor Driver with a 10 to 10 FRC Female Connector.

    Steps - 5 ( 0f 13 )

  • Connect the 12V pin of PWM & Motor Voltage header of DC Motor Driver with the 12V header of AVR Trainer Board-100 with a 1 to 1 Connector.

    Steps - 6 ( 0f 13 )

  • Connect the Robot connector to the Output header of the DC Motor Driver.

    Steps - 7 ( 0f 13 )

  • Switch off the Mode Switch of DC Motor Driver.

    Steps - 8 ( 0f 13 )

  • Connect the X, Y, Z, VCC and GND pins of Accelerometer Sensor header of 3-axis Accelerometer Sensor with PA0, PA1, PA2, VCC and GND pin of PortA header of AVR Trainer Board-100 with a 5 to 5 Connector.

    Steps - 9 ( 0f 13 )

  • Connect the ISP header of AVR Trainer Board-100 with AVR USB Programmer header of AVR USB Programmer with a 10 to 10 FRC Female Connector.

    Steps - 10 ( 0f 13 )

  • Connect the AVR USB Programmer to the PC/Laptop's USB Port directly or with the help of USB AM-AF Cable.

    Steps - 11 ( 0f 13 )

  • Switch on the power with the help of Power Switch of AVR Trainer Board-100.

    Steps - 12 ( 0f 13 )

  • Download Accelerometer based Hand Gesture Controlled Robot with ATmega32 Hex file to AVR Trainer Board-100 with the help of SinaProg Hex downloader and AVR USB Programmer.

    Steps - 13 ( 0f 13 )

Downloads

Accelerometer based Hand Gesture Controlled Robot with ATmega32 C File
  • 60 downloads
  • 5 Kb
Accelerometer based Hand Gesture Controlled Robot with ATmega32 Circuit Diagram
  • 55 downloads
  • 82 Kb
Accelerometer based Hand Gesture Controlled Robot with ATmega32 Hex File
  • 42 downloads
  • 3 Kb
Alphanumeric LCD Header File v1.0
  • 1763 downloads
  • 1 Kb
ADXL335 Header File v1.0
  • 163 downloads
  • 2 Kb
ADC Header File v1.0
  • 1176 downloads
  • 2 Kb

Post a Comment