۴X4 Keypad Controlled Wireless Robot with ATmega16 using 433MHz RF

4X4-Keypad-Controlled-Wireless-Robot-with-AVR-ATmega16-Microcontroller-using-433MHz-RF-Receiver-Circuit-Diagram (1)

4X4-Keypad-Controlled-Wireless-Robot-with-AVR-ATmega16-Microcontroller-using-433MHz-RF-Transmitter-Circuit-Diagram-1024x601

 

C Program

//**************************************************************//
//System Clock                              :۱MHz
//Software                                     :Atmel Studio 6
//LCD Data Interfacing                :۸-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           ۱۰۰۰۰۰۰
/*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           KEYPAD_PORT           PORTC
/*Defines a macro for the keypad.h header file. KEYPAD_PORT is the microcontroller PORT Register to which 4X4 keypad is connected. Default PORT Register in keypad.h header file is PORTB*/

#define           KEYPAD_PIN           PINC
/*Defines a macro for the keypad.h header file. KEYPAD_PIN is the microcontroller PIN Register to which 4X4 keypad is connected. Default PIN Register in keypad.h header file is PINB*/

#include<avr/keypad.h>
/*Includes keypad.h header file which defines one function: read_keypad () to read the 4X4 keypad. Keypad header file version is 1.1*/

#define           LCD_DATA_PORT           PORTA
/*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*/

int main(void)
{

DDRC=0x0f;
//PortC’s upper 4 bits are declared input and lower 4 bits are declared output(4X4 Keypad is connected)*/

PORTC=0xff;
//PortC’s lower 4 bits are given high value and pull-up are enabled for higher 4 bits*/

DDRB=0x0f;
/*PB0, PB1, PB2 and PB3 pins of PortB are declared output (433MHz RF Transmitter is connected)*/

DDRA=0xff;
/*All the 8 pins of PortA 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)*/

unsigned char keypad_value;
/*Variable declarations and initialisations*/

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(“Press 2,4,6,8,5:”);
/*String display in 1st row of LCD*/

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

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

keypad_value = read_keypad();
/*Scan’s 4X4 keypad and returns pressed key value or default value*/

/*Checking if any key is pressed or not*/
if(keypad_value != 0xff)
{

/*Checking which key of the keypad is pressed to move the robot in different direction*/
if(keypad_value == 0x02)
{

PORTB=0x0A;
/*Transmitter will transmit 0x0A to drive Robot in forward direction*/

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

}
else if(keypad_value == 0x08)
{

PORTB=0x05;
/*Transmitter will transmit 0x05 to drive Robot in reverse direction*/

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

}
else if(keypad_value == 0x04)
{

PORTB=0x02;
/*Transmitter will transmit 0x02 to drive Robot in left direction*/

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

}
else if(keypad_value == 0x06)
{

PORTB=0x08;
/*Transmitter will transmit 0x08 to drive Robot in right direction*/

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

}
else if(keypad_value == 0x05)
{

PORTB=0x0F;
/*Transmitter will transmit 0x0f to stop Robot*/

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

}
else
{

;
/*Null statement*/

}

}
else
{

;
/*Null statement*/

}

}

}
/*End of Program*/

Connection Guide

The step-by-step connection guide for 4X4 Keypad Controlled Wireless Robot with ATmega16 using 433MHz RF project is as follows:

Transmitter Connection Guide

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

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

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

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

  • Connect PortC header of AVR Trainer Board-100 with Keypad header of 4X4 Keypad with a 10 to 10 FRC Female Connector.

  • Connect PortB header of AVR Trainer Board-100 with RF Transmitter header of RF Transmitter Board with a 10 to 10 FRC Female Connector.

  • Connect the TE bar pin and GND of RF Transmitter Jumper header with a jumper.

  • Set the address of RF Transmitter to 0x00 with the help of 8 way DIP switch in RF Transmitter Board.

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

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

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

  • Download the 4X4 Keypad Controlled Wireless Robot with ATmega16 using 433MHz RF Hex file to AVR Trainer Board-100 with the help of SinaProg Hex downloader and AVR USB Programmer.

Receiver Connection Guide

  • Insert the DC Pin of 12V, 1A DC Adapter to the DC Socket of Power Supply Board.

  • Connect the 5V and GND pins of 5V header and GND header of Power Supply Board to VCC and GND pins of Input header of DC Motor Driver and RF Receiver header of RF Receiver Board with 1 to 1 Female Connectors.

  • Set the address of RF Receiver to 0x00 with the help of 8 way DIP switch in RF Receiver Board.

  • Connect the D8, D9, D10 and D11 pins of RF Receiver header of RF Receiver Board with I/P1, I/P2, I/P3 and I/P4 pins of Input header of DC Motor Driver with 1 to 1 Female Connectors.

  • Connect the 12V pin of PWM & Motor Voltage header of DC Motor Driver with the 12V header of Power Supply Board with a 1 to 1 Connector.

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

  • Switch off the Mode Switch of DC Motor Driver.

  • Switch on the power with the help of Power Switch of Power Supply Board.

Press different keys of the 4X4 keypad and driver your robot wirelessly.


دوستان کد ها را در ورد کپی کنید درست نمایش داده میشود و قابل فهم تر است


Hardwares Required

  • AVR Trainer Board-100-1pc

  • AVR USB Programmer-1pc

  • ۱۲V, 1A DC Adapter-2pcs

  • ۱۶X2 Alphanumeric LCD(JHD162A)-1pc

  • ۴X4 Keypad-1pc

  • DC Motor Driver-1pc

  • Robot-1pc

  • RF Transmitter & Receiver Board-1pc

  • Power Supply Board-1pc

  • ۱ to 1 Connector-12pcs

  • ۱۰ to 10 FRC Female Connector-4pcs

  • USB AM-AF Cable(Optional)-1pc

Softwares Required

  • AVR Studio 6

  • SinaProg Hex Downloader

  • USBasp Driver

 

 

 

منبع: http://www.ablab.in/

پاسخ دهید

نشانی ایمیل شما منتشر نخواهد شد. بخش‌های موردنیاز علامت‌گذاری شده‌اند *

*