Control 4WD Robot With Tv Remote Using Arduino UNO and L293D
by moh_nml in Circuits > Arduino
2225 Views, 2 Favorites, 0 Comments
Control 4WD Robot With Tv Remote Using Arduino UNO and L293D
How to use your TV remote or any Remote control to control 4WD Robot,
No shield required ,
Connecting the 4 Motor with L293D ic ,
First You Need to Know the Code for Every Remote Control Button You Need to Use
- Download IR remote library :
- Run IRrecvDemo example .
- Open the serial monitor , and push any button you need , and the code will appear in the serial monitor,
- Save all the button code , you will use it in your project
Downloads
Hardware Required
- Arduino UNO
- 4 Motor with wheel.
- L293D
- IR Receiver .
- TV Remote
- Battery's
- Battery Holder
https://goo.gl/45PfkU
Circuit Schematic & Component Assembly
I'm using L293D for control all the motor's :
Pin 1 +9+16 to 5v pin in arduino board .
Pin 2 to Arduino pin 3
Pin 3 to Motor 1
Pin 4+5 to GND
Pin 6 to Motor 1
Pin 7 to Arduino pin 5
Pin 8 to external 9v battery
Pin 10 to Arduino pin 9
Pin 11 to Motor 2
Pin 12 +13 to GND
Pin 14 to Motor 2
Pin 15 to Arduino pin 10
---------
IR Receiver
1 = Arduino Pin A0
2 = GND
3 = 3.3v
Coding
#include
int motorL1 = 3; // Motor 1
int motorL2 = 5 ; // Motor 1
int motorR1 = 9 ; // Motor 2
int motorR2 = 10 ; // Motor 2
int IR = A0 ;
IRrecv irrecv(IR);
decode_results results
; void setup()
{ pinMode ( motorL1 , OUTPUT ) ;
pinMode ( motorL2 , OUTPUT ) ;
pinMode ( motorR1 , OUTPUT ) ;
pinMode ( motorR2 , OUTPUT ) ;
//-----------------
pinMode(IR, INPUT);
Serial.begin(9600);
irrecv.enableIRIn();
}
void loop()
{
if (irrecv.decode(&results)) {
if (results.value == 0xFF00FF) {
Serial.println ("FORWARD");
forward ();
delay ( 100 );
}
if (results.value == 0xFF807F) {
Serial.println ("BACKWARD");
backward ();
}
if (results.value == 0xFF40BF) {
Serial.println ("RIGHT");
right ();
}
if (results.value == 0xFFC03F) {
Serial.println ("LEFT");
left ();
}
if (results.value == 0xFFE01F)
{
Serial.println ("STOP");
STOP ();
}
irrecv.resume(); // Receive the next value
}
delay(100);
}
void forward ()
{
digitalWrite ( motorL1 , HIGH ) ;
digitalWrite ( motorL2 , LOW ) ;
digitalWrite ( motorR1 , HIGH ) ;
digitalWrite ( motorR2 , LOW ) ;
}
void backward ()
{
digitalWrite ( motorL1 , LOW ) ;
digitalWrite ( motorL2 , HIGH ) ;
digitalWrite ( motorR1 , LOW ) ;
digitalWrite ( motorR2 , HIGH ) ;
}
void right ()
{
digitalWrite ( motorL1 , LOW ) ;
digitalWrite ( motorL2 , HIGH ) ;
digitalWrite ( motorR1 , LOW ) ;
digitalWrite ( motorR2 , LOW ) ;
}
void left ()
{
digitalWrite ( motorL1 , LOW ) ;
digitalWrite ( motorL2 , LOW ) ;
digitalWrite ( motorR1 , LOW ) ;
digitalWrite ( motorR2 , HIGH ) ; }
void STOP ()
{
digitalWrite ( motorL1 , LOW ) ;
digitalWrite ( motorL2 , LOW ) ;
digitalWrite ( motorR1 , LOW ) ;
digitalWrite ( motorR2 , LOW ) ; }