Arduino Project Report IR Car
Arduino Project Report IR Car
Using Arduino
Instructor:
Team Members:
Submission Date:
Objective:
The objective of this project is to design and implement an Arduino based car that can
be controlled using, infrared remote controlling kits by mini ultra-thin infrared remote
controlling, and uses a 38 KHz IR receiver to detect the remote signal. The car should
work within line of sight to efficiently detect the remote signal. The remote buttons for
up, down, left, and right could be used to control the car movements.
Introduction:
As the remote controlling is used almost in every controlled device although the medium
could be Radio controlled or the Infrared. In this project we will be using the Infrared
remote controller to control a car and using an Arduino as the controller. The IR signal
will be received using an IR receiver that will receive a signal with a carrier frequency of
38 KHz and the signal will be decoded to detect the left, right, forward or back
commands. The commands than be further used to call the programed functions for left,
right or forward, back movements of the car. The movement control functions will than
transmit a digital signal to the H-Bridge motor driver L298 along with a PWM based
speed control signal onto the enable input of the H-Bridge. The motor driver will amplify
the digital signals and control the motor rotation direction i.e. clockwise or
counterclockwise and the RPM (revolutions per minute) based on the PWM signal duty
cycle. The remote controller we will be using will have the following specifications:
Figure 1
Arduino USB programming cable
Figure 2
IR-Remote controller:
Figure 3
Breadboard
Figure 4
Car with battery:
Figure 5
Figure 6
L298 Motor Driver:
Figure 7
Wire Connections:
Figure 8
Project Wiring Chart:
Figure 9
Conclusion:
In this project, we have successfully designed and implemented an IR remote controlled
car that has been programmed to detect the IR signals and perform the left, right,
forward or back motions based on these commands received. The hardware used for
receiving these signals is a TSOP infrared receiver designed to receive a 38 KHz base
frequency signal. That signal is than transmitted digitally to the Arduino pin connected to
the receiver and is decoded via code and the IR library. The decoded signal is than at
last used to call the functions controlling the car motions via H-Bridge motor driver.
Arduino Program:
#include <IRremote.h>
////////// IR REMOTE CODES //////////
#define F 16736925 // FORWARD
#define B 16754775 // BACK
#define L 16720605 // LEFT
#define R 16761405 // RIGHT
#define S 16712445 // STOP
#define UNKNOWN_F 5316027 // FORWARD
#define UNKNOWN_B 2747854299 // BACK
#define UNKNOWN_L 1386468383 // LEFT
#define UNKNOWN_R 553536955 // RIGHT
#define UNKNOWN_S 3622325019 // STOP
#define RECV_PIN 12
IRrecv irrecv(RECV_PIN);
decode_results results;
unsigned long val;
unsigned long preMillis;
/**
* BEGIN DEFINE FUNCTIONS
*/
void forward(){
digitalWrite(ENA,HIGH);
digitalWrite(ENB,HIGH);
digitalWrite(IN1,HIGH);
digitalWrite(IN2,LOW);
digitalWrite(IN3,LOW);
digitalWrite(IN4,HIGH);
Serial.println("go forward!");
}
void back(){
digitalWrite(ENA,HIGH);
digitalWrite(ENB,HIGH);
digitalWrite(IN1,LOW);
digitalWrite(IN2,HIGH);
digitalWrite(IN3,HIGH);
digitalWrite(IN4,LOW);
Serial.println("go back!");
}
void left(){
analogWrite(ENA,carSpeed);
analogWrite(ENB,carSpeed);
digitalWrite(IN1,LOW);
digitalWrite(IN2,HIGH);
digitalWrite(IN3,LOW);
digitalWrite(IN4,HIGH);
Serial.println("go left!");
}
void right(){
analogWrite(ENA,carSpeed);
analogWrite(ENB,carSpeed);
digitalWrite(IN1,HIGH);
digitalWrite(IN2,LOW);
digitalWrite(IN3,HIGH);
digitalWrite(IN4,LOW);
Serial.println("go right!");
}
void stop(){
digitalWrite(ENA, LOW);
digitalWrite(ENB, LOW);
Serial.println("STOP!");
}
void setup() {
Serial.begin(9600);
pinMode(IN1,OUTPUT);
pinMode(IN2,OUTPUT);
pinMode(IN3,OUTPUT);
pinMode(IN4,OUTPUT);
pinMode(ENA,OUTPUT);
pinMode(ENB,OUTPUT);
stop();
irrecv.enableIRIn();
}
void loop() {
if (irrecv.decode(&results)){
preMillis = millis();
val = results.value;
Serial.println(val);
irrecv.resume();
switch(val){
case F:
case UNKNOWN_F: forward(); break;
case B:
case UNKNOWN_B: back(); break;
case L:
case UNKNOWN_L: left(); break;
case R:
case UNKNOWN_R: right();break;
case S:
case UNKNOWN_S: stop(); break;
default: break;
}
}
else{
if(millis() - preMillis > 500){
stop();
preMillis = millis();
}
}
}