1. DEPARTMENT OF ECE, UIET
PUSSGRC, HOSHIARPUR
PROJECT REPORT
on
Arduino based Windows Remote Control
SUBMITTED TO: SUBMITTED BY:
Mr. Suresh Kumar Sourabh Kumar (SG-14540)
Sunil Choudhary(SG-14542)
Vilayat Ali (SG-14548)
Vishav Gupta (SG-14549)
2. Acknowledgement
We, the project team members hereby acknowledge various
sources and individuals who have been a major part in the
completion of the project.
First of all, we are thankful to Mr. Suresh Kumar (Ast. Prof. UIET
Hoshiapur) for his guidiance and helping us in building this
project.
We would also like to thank our friends and classmates for
helping us and last but not the least we would like to acknowledge
www.arduino.cc.
4. Abstract
Presented here is a project that turns your Arduino into a remote control.
almost everything is controlled by a remote. This project allows you
Infrared (IR) remotes have been very prominent since 1980’s. In today’s
world to control the master volume of a Windows PC, a television set,
set top box, home theatre system and the like.
Introduction to Arduino
The Arduino Uno is a microcontroller board based on the ATmega328.
It has 14 digital input/output pins (of which 6 can be used as PWM
outputs), 6 analog inputs, a 16 MHz ceramic resonator, a USB
connection, a power jack, an ICSP header, and a reset button. It contains
everything needed to support the microcontroller; simply connect it to a
computer with a USB cable or power it with a AC-to-DC adapter or
battery to get started.
Features of Arduino board
Microcontroller ATmega328
Operating Voltage 5V
Input Voltage (recommended) 7-12V
Input Voltage (limits) 6-20V
Digital I/O Pins 14 (of which 6 provide PWM output)
Analog Input Pins 6
DC Current per I/O Pin 40 Ma
DC Current for 3.3V Pin 50 mA
Flash Memory 32 KB (ATmega328) of which 0.5 KB used by boot
loader
SRAM 2 KB (ATmega328)
EEPROM 1 KB (ATmega328)
Clock Speed 16 MHz
Power To Arduino
The Arduino Uno can be powered via the USB connection or with an
external power supply. The power source is selected automatically.
5. External (non-USB) power can come either from an AC-to-DC adapter
(wall-wart) or battery. The adapter can be connected by plugging a
2.1mm center-positive plug into the board's power jack. Leads from a
battery can be inserted in the Ground and Vin pin headers of the
POWER connector. The board can operate on an external supply of 6 to
20 volts. If supplied with less than 7V, however, the 5V pin may supply
less than five volts and the board may be unstable.
If using more than 12V, the voltage regulator may overheat and damage
the board. The recommended range is 7 to 12 volts.
The power pins are as follows:
VIN. The input voltage to the Arduino board when it's using an
external power source (as opposed to 5 volts from the USB connection
or other regulated power source). You can supply voltage through this
pin, or, if supplying voltage via the power jack, access it through this
pin.
5V.This pin outputs a regulated 5V from the regulator on the board.
The board can be supplied with power either from the DC power jack (7
- 12V), the USB connector (5V), or the VIN pin of the board (7-12V).
3V3. A 3.3 volt supply generated by the on-board regulator.
Maximum current draw is 50 mA.
GND. Ground pins.
Each of the 14 digital pins (pins 0 to 13) on the Uno can be used as an
input or output, using pinMode(), digitalWrite(), and digitalRead()
functions. They operate at 5 volts. Each pin can provide or receive a
maximum of 40 mA and has an internal pull-up resistor (disconnected
by default) of 20-50 kΩ. In addition, some pins have specialized
functions:
Serial: 0 (RX) and 1 (TX). Used to receive (RX) and transmit (TX)
TTL serial data.
These pins are connected to the corresponding pins of the ATmega8U2
USB-to-TTL Serial chip.
External Interrupts: 2 and 3. These pins can be configured to trigger
an interrupt on a low value, a rising or falling edge, or a change in value.
6. PWM: 3, 5, 6, 9, 10, and 11. Provide 8-bit PWM output with the
analogWrite() function.
SPI: 10 (SS), 11 (MOSI), 12 (MISO), 13 (SCK). These pins support
SPI communication using the SPI library.
LED: 13. There is a built-in LED connected to digital pin 13. When the
pin is HIGH value, the LED is on, when the pin is LOW, it's off. The
Uno has 6 analog inputs, labeled A0 through A5, each of which provide
10 bits of resolution (i.e. 1024 different values). By default they measure
from ground to 5 volts, though is it possible to change the upper end of
their range using the AREF pin and the analogReference() function. The
programs written for Arduino are called sketches. For the sketch to work
on your Arduino Uno, there are two hardware related settings you need
to make in the Arduino IDE –
Board
Serial Port
The basic structure of the Arduino sketch is fairly simple and has two
required functions:
void setup(){statements;}
void loop(){statements;}
Where setup() is the preparation, loop() is the execution. Both functions
are required for the program to work. The setup function should follow
the declaration of any variables at the very beginning of the program. It
is the first function to run in the program, is run only once, and is used to
set pinMode or initialize serial communication. The loop function
follows next and includes the code to be executed continuously –
reading inputs, triggering outputs, etc. This function is the core of all
Arduino programs and does the bulk of the work.
setup()
The setup() function is called once when your program starts. Use it to
initialize pin modes, or begin serial. It must be included in a program
even if there are no statements to run.
void setup() { pinMode(pin, OUTPUT); // sets the 'pin' as output }
7. loop()
After calling the setup() function, the loop() function does precisely
what its name suggests, and loops consecutively, allowing the program
to change, respond, and control the Arduino board.
void loop() { digitalWrite(pin, HIGH); // turns 'pin' on delay(1000); //
pauses for one second digitalWrite(pin, LOW); // turns 'pin' off
delay(1000); // pauses for one second }
pinMode(pin, mode)
Used in void setup() to configure a specified pin to behave either as an
INPUT or an OUTPUT.
pinMode(pin, OUTPUT); // sets ‘pin’ to output.
There are also convenient pullup resistors built into the Atmega chip that
can be accessed from software. These built-in pullup resistors are
accessed in the following manner:
pinMode(pin, INPUT); // set ‘pin’ to input
digitalWrite(pin, HIGH); // turn on pullup resistors
Pull-up resistors would normally be used for connecting inputs like
switches. Notice in the above example it does not convert pin to an
output, it is merely a method for activating the internal pull-ups.
Pins configured as OUTPUT can provide 40 mA (milliamps) of current
to other devices/circuits. This is enough current to brightly light up an
LED (don't forget the series resistor), but not enough current to run most
relays, solenoids, or motors. Short circuits on Arduino pins and
excessive current can damage or destroy the output pin, or damage the
entire AT mega chip. It is often a good idea to connect an OUTPUT pin
to an external device in series with a 470_ or 1K_ resistor.
digitalRead(pin)
Reads the value from a specified digital pin with the result either HIGH
or LOW. The pin can be specified as either a variable or constant (0-13).
value = digitalRead(Pin); // sets 'value' equal to // the input pin
8. digitalWrite(pin, value)
Outputs either logic level HIGH or LOW at (turns on or off) a specified
digital pin.
The pin can be specified as either a variable or constant (0-13).
digitalWrite(pin, HIGH); // sets 'pin' to high
analogRead(pin)
Reads the value from a specified analog pin with a 10-bit resolution.
This function only works on the analog in pins (0-5). The resulting
integer values range from 0 to 1023.
value = analogRead(pin); // sets 'value' equal to 'pin'
Note: Analog pins unlike digital ones, do not need to be first declared as
INPUT nor OUTPUT.
analogWrite(pin, value)
Writes a pseudo-analog value using hardware enabled pulse width
modulation (PWM) to an output pin marked PWM. On Uno, this
function works on pins 3, 5, 6, 9, 10, and 11. The value can be specified
as a variable or constant with a value from 0-255. analogWrite(pin,
value); // writes 'value' to analog 'pin'
A value of 0 generates a steady 0 volts output at the specified pin; a
value of 255 generates a steady 5 volts output at the specified pin. For
values in between 0 and 255, the pin rapidly alternates between 0 and 5
volts - the higher the value, the more often the pin is HIGH (5 volts). For
example, a value of 64 will be 0 volts three-quarters of the time, and 5
volts one quarter of the time; a value of 128 will be at 0 half the time and
255 half the time; and a value of 192 will be 0 volts one quarter of the
time and 5 volts threequarters of the time. Because this is a hardware
function, the pin will generate a steady wave after a call to analogWrite
in the background until the next call to analogWrite (or a call to
digitalRead or digitalWrite on the same pin).
Note: Analog pins unlike digital ones, do not need to be first declared as
INPUT nor OUTPUT.
9. delay(ms)
Pauses a program for the amount of time as specified in milliseconds,
where 1000 equals
1 second. delay(1000); // waits for one second
millis()
Returns the number of milliseconds since the Arduino board began
running the current program as an unsigned long value.
value = millis(); // sets ‘value’ equal to millis()
Note: This number will overflow (reset back to zero), after
approximately 9 hours.
Serial.begin(rate)
Opens serial port and sets the baud rate for serial data transmission. The
typical baud rate for communicating with the computer is 9600 although
other speeds are supported.
void setup() { Serial.begin(9600); // opens serial port } // sets data rate to
9600 bps
Note: When using serial communication, digital pins 0 (RX) and 1 (TX)
cannot be used at the same time.
ATMEGA 328
Features
High Performance, Low Power AVR® 8-Bit Microcontroller
Advanced RISC Architecture
– 131 Powerful Instructions – Most Single Clock Cycle Execution
– 32 x 8 General Purpose Working Registers
– Fully Static Operation
– Up to 20 MIPS Throughput at 20 MHz
– On-chip 2-cycle Multiplier
High Endurance Non-volatile Memory Segments
– 4/8/16/32K Bytes of In-System Self-Programmable Flash progam
memory
– 256/512/512/1K Bytes EEPROM (ATmega48P/88P/168P/328P)
10. – 512/1K/1K/2K Bytes Internal SRAM (ATmega48P/88P/168P/328P)
– Write/Erase Cycles: 10,000 Flash/100,000 EEPROM
– Data retention: 20 years at 85°C/100 years at 25°C(1)
– Optional Boot Code Section with Independent Lock Bits
Peripheral Features
– Two 8-bit Timer/Counters with Separate Prescaler and Compare Mode
– One 16-bit Timer/Counter with Separate Prescaler, Compare Mode,
and CaptureMode
– Real Time Counter with Separate Oscillator
– Six PWM Channels
– 8-channel 10-bit ADC in TQFP and QFN/MLF package
– 6-channel 10-bit ADC in PDIP Package
– Programmable Serial USART
– Master/Slave SPI Serial Interface
– Byte-oriented 2-wire Serial Interface (Philips I2C compatible)
– Programmable Watchdog Timer with Separate On-chip Oscillator
– On-chip Analog Comparator
– Interrupt and Wake-up on Pin Change
Special Microcontroller Features:
– Power-on Reset and Programmable Brown-out Detection
– Internal Calibrated Oscillator
– External and Internal Interrupt Sources
– Six Sleep Modes: Idle, ADC Noise Reduction, Power-save, Power-
down, Standby, and Extended Standby
I/O and Packages:
– 23 Programmable I/O Lines
– 28-pin PDIP, 32-lead TQFP, 28-pad QFN/MLF and 32-pad QFN/MLF
Operating Voltage:
– 1.8 - 5.5V for ATmega48P/88P/168PV
– 2.7 - 5.5V for ATmega48P/88P/168P
– 1.8 - 5.5V for ATmega328P
12. Pin diagram:
Pin Description :
VCC
Digital supply voltage.
GND
Ground.
Port B (PB7:0) XTAL1/XTAL2/TOSC1/TOSC2
Port B is an 8-bit bi-directional I/O port with internal pull-up resistors
(selected for each bit). The Port B output buffers have symmetrical drive
characteristics with both high sink and source Capability. As inputs, Port
B pins that are externally pulled low will source current if the pull-up
resistors are activated. The Port B pins are tri-stated when a reset
condition becomes active, even if the clock is not running. Depending on
the clock selection fuse settings, PB6 can be used as input to the
inverting Oscillator amplifier and input to the internal clock operating
13. circuit. Depending on the clock selection fuse settings, PB7 can be used
as output from the inverting Oscillator amplifier.
Port C (PC5:0)
Port C is a 7-bit bi-directional I/O port with internal pull-up resistors
(selected for each bit). The PC5.0 output buffers have symmetrical drive
characteristics with both high sink and source capability. As inputs, Port
C pins that are externally pulled low will source current if the pull-up
resistors are activated. The Port C pins are tri-stated when a reset
condition becomes active, even if the clock is not running.
PC6/RESET
If the RSTDISBL Fuse is programmed, PC6 is used as an I/O pin. Note
that the electrical characteristics of PC6 differ from those of the other
pins of Port C. If the RSTDISBL Fuse is unprogrammed, PC6 is used as
a Reset input. A low level on this pin for longer than the minimum pulse
length will generate a Reset, even if the clock is not running.
Shorter pulses are not guaranteed to generate a Reset.
Port D (PD7:0)
Port D is an 8-bit bi-directional I/O port with internal pull-up resistors
(selected for each bit). The Port D output buffers have symmetrical drive
characteristics with both high sink and source capability. As inputs, Port
D pins that are externally pulled low will source current if the pull-up
resistors are activated. The Port D pins are tri-stated when a reset
condition becomes active,even if the clock is not running.
AVCC
AVCC is the supply voltage pin for the A/D Converter, PC3:0, and
ADC7:6. It should be externally connected to VCC, even if the ADC is
not used. If the ADC is used, it should be connected to VCC through a
low-pass filter. Note that PC6..4 use digital supply voltage, VCC.
AREF
AREF is the analog reference pin for the A/D Converter.
14. ADC7:6 (TQFP and QFN/MLF Package Only)
In the TQFP and QFN/MLF package, ADC7:6 serve as analog inputs to
the A/D converter..
Standard data formats
There are two common data formats for IR control: RC5 coding and
NEC coding.
RC5 code. RC5 code uses a bi-phase coding, and the carrier frequency is
fixed at 36kHz. Transmission of the data begins with two start bits
followed by a toggle bit (Fig. 1). Toggle bit changes its value at each
new key press. Five address bits represent the address of the device to be
controlled. Six command bits contain the information to be transmitted.
Each bit in the data consists of half a bit period with no transmission
and half a bit period with a burst of 32 pulses at 36kHz. The most
suitable IR receivers for receiving RC5 code are those with AGC2
setting and a band-pass frequency of 36kHz. Some examples are
TSOP1236, TSOP4836, TSOP34836, TSOP39236 and TSOP36236.
Fig. 1: RC5 transmission code
15. NEC code. NEC code uses bursts at a carrier frequency of 38kHz. It
starts transmission using a leader code, a burst with a length of 9ms,
followed by a pause of 4.5ms and then the data (Fig. 2). The original
purpose of this leader code was to let the internal control loops in the
receiver modules to settle. After transmitting the data, only the leader
code and a single bit are transmitted repeatedly for as long as a key is
pressed. A special property of this code is a constant word length in
combination with pulse distance modulation. Address and data bits are
transmitted twice, first as a normal byte, followed by an inverted byte.
The half period burst portion of each bit contains 22 pulses, each with
a width of 8.77μs and a period of 26.3μs. 0 is represented by a pulse
distance of 1.125ms, and 1 by a pulse distance of 2.25ms. Eight address
bits are used to identify the device to be controlled. Further eight bits are
used for transmission of command data. As mentioned above, the words
are always followed, without a pause, by inverted words. For example,
transmission of address 00110111 and command data 00011010 is
performed by sending bits as:
“00110111’11001000’00011010’11100101”
In a special version of NEC code, the pre-burst, including all address
and data bits, is repeated in each 108ms time slot for as long as the key
is pressed.
Fig. 2: NEC transmission code
16. IR receiver modules:
The most suitable IR receivers for receiving NEC code are those with
AGC4 setting as these have the best noise suppression while still
supporting this data format.
Some examples are TSOP4438, TSOP58438 and TSOP75438.
Receiver modules for different carrier frequencies are given in the Table
below.
Circuit and working:
Circuit diagram of Arduino PC volume control is shown in Fig. 3.
Hardware components required are Arduino Uno, TSOP1738 IR
receiver, breadboard and some jumper wires.
Working of the project is fairly simple. Arduino Uno decodes the key of
the remote and then compares it with predefined variables to figure out
which key is pressed. If it finds a match, it sends the signal to the PC,
which is interpreted by Remote Volume Control software (designed by
author), which further performs the required task. Screenshot of Remote
Volume Control software is shown in Fig. 4. The most important step is
to configure the desired remote control device with Arduino Uno.
17. Fig. 3: Circuit diagram of Arduino based Windows PC volume
remote control
18. Fig. 4: Screenshot of Remote Volume Control software
Software
The source codes (IR_Key_Test.ino and IR_Final.ino) are written in
Arduino programming language. The software used to program Arduino
Uno is Arduino IDE, which can be downloaded free of cost from www.
arduino.cc/en/Main/Software Arduino, which is an open source
software, makes it easy to write and upload the code to the board. It runs
on Windows, Mac OS X and Linux. The environment is written in Java
and based on Processing and other open source software. The library
used in this project is IR remote library. It allows Arduino Uno to
decode IR signals coming from the remote. To install the library, copy
IR remote folder and paste it in the following location:
Documents>Arduino>libraries folder
To communicate between Arduino Uno and PC, mode of
communication used is serial communication. You need to install
Remote Volume Control software on the targeted PC, which
communicates with Arduino Uno and accordingly performs the task.
19. This software runs in the background and automatically starts when the
PC boots.
Initial setup
Step 1. To configure your desired remote control device, install IR
remote library and open IR_Key_Test. ino code from Arduino IDE.
Select the correct board from Tools→Board menu in Arduino IDE, and
burn the program (sketch) through the standard USB port in your
computer.
Step 2. After uploading the code, open Serial Monitor in Arduino IDE.
Point the remote control towards TSOP receiver module and press the
key that you want to assign for volume up function continuously. Note
the key code number that will repeat again and again when the key is
pressed. Screenshot of the example is shown in Fig. 5.
Fig 5:- (a) Example of Key configuration
20. Fig:- 5 (b) Example of key configuration
Key code for volume up function as per current serial data is 45135.
Note that some remotes send value 65535 or FFFF after sending the key
code. Sometimes, there might be abrupt values due to ambient light or
interference, so take five to six readings before assigning the key code.
Similarly, repeat the above procedure to find the key codes for volume
down and mute functions.
21. Step 3. After noting down the key codes for all functions, open
IR_Final.ino code and write down your key codes as shown in Fig. 6.
Save and compile the code.
Fig. 6: Screenshot of IR_Final.ino
22. Testing the project
After uploading IR_Final.ino code to Arduino Uno, connect it to your
PC and open Device Manager. Note the COM port assigned to Arduino
Uno. Here, Arduino Uno is assigned COM3 (Fig. 7). Install Remote
Volume Control software and start it. Select COM3 in COM Ports menu
and select 9600 baud rate from Baud Rate menu. Click on Connect, and
if all goes well, volume of the PC will be controlled by your desired
remote.
Fig.7: Device Manager Window
23. Arduino based Windows PC volume remote control is shown in Fig. 8.
Fig. 8:
------------END----------