Category :Tutorials

Byamber

Graphical Programming Tutorial for Arduino – Infrared Remote Control the Lamp

Introduction

In this lesson, we will show how to use the IR control an LED. When we press the “OK” button, the LED will be turned on, and when we press the “OK” button again, the LED will be truned off.

Preparations

HARDWARE

  • Osoyoo UNO Board (Fully compatible with Arduino UNO rev.3) x 1
  • Infrared Receiver x 1
  • Remote Controller x 1
  • LED x 1
  • 200 ohm Resistor x 1
  • Breadboard x 1
  • Jumpers
  • USB Cable x 1
  • PC x 1

Connection

Build the circuit as below:

CODE PROGRAM

After above operations are completed, connect the Arduino board to your computer using the USB cable. The green power LED (labelled PWR) should go on.Open the Graphical Programming software Mixly and follow the next operations:

Click Save aftogramming is done. Select the board type and serial port before uploading. For instause a Uno board, just select Arduino/Genuino Uno: if you use a Mega2560, select Arduino/Genuino Mega or Mega2560.

Select the serial device of the Arduino board from the COM menu. This is likely to be COM3 or higher (COM1 and COM2 are usually reserved for hardware serial ports). To find out, you can disconnect your Arduino board and re-open the menu; the entry that disappears should be the Arduino board. Reconnect the board and select that serial port.

Next,upload the code. If the uploading fails, check and correct the code according to the prompts.

Finally, the staus will change to ‘Upload success!’.

Running Result

A few seconds after the upload finishes, press the “OK” button of a remote controller, the LED attached connected to D12 will be light up. Then press “OK” again, and the LEDs will go out.

Byamber

Graphical Programming Tutorial for Arduino – IR Remote Receiver Module and Controller

INTRODUCTION

IR, or infrared, communication is a common, inexpensive, and easy to use wireless communication technology. IR light is very similar to visible light, except that it has a slightlty longer wavelength. This means IR is undetectable to the human eye – perfect for wireless communication. For example, when you hit a button on your TV remote, an IR LED repeatedly turns on and off, 38,000 time a second, to transmit information (like volume or channel control) to an IR photo sensor on your TV.

This tutorial will first explain the inner workings of common IR communication protocols. Then we will go over three examples that will allow you to transmit and receive IR data using an Arduino. In this example, we will read incoming IR data from a common remote control using the 1838B IR photo sensor.

Preparations

HARDWARE

  • Osoyoo UNO Board (Fully compatible with Arduino UNO rev.3) x 1
  • Infrared Receiver x 1
  • Remote Controller x 1
  • Jumpers
  • USB Cable x 1
  • PC x 1

About the IR

WHAT IS IR?

Infra-Red light is actually normal light with a particular colour. We humans can’t see this colour because its wave length of about 950nm is below the visible spectrum. That’s one of the reasons why IR is chosen for remote control purposes, we want to use it but we’re not interested in seeing it. Another reason is because IR LEDs are quite easy to make, and therefore can be very cheap, thus making it ideal for us hobbyists to use IR control for our own projects.

We need to konw there are many more sources of Infra-Red light. The sun is the brightest source of all, but there are many others, like: light bulbs, candles, central heating system, and even our body radiates Infra-Red light.

A common modulation scheme for IR communication is something called 38kHz modulation. There are very few natural sources that have the regularity of a 38kHz signal, so an IR transmitter sending data at that frequency would stand out among the ambient IR. 38kHz modulated IR data is the most common, but other frequencies can be used.

When you hit a key on your remote, the transmitting IR LED will blink very quickly for a fraction of a second, transmitting encoded data to your appliance.

If you were to hook an oscilloscope up to your TV remote’s IR LED, you would see a signal similar to the one above. This modulated signal is exactly what the receiving system sees. However, the point of the receiving device is to demodulate the signal and output a binary waveform that can be read by a microcontroller. When you read the OUT pin of the VS1838B with the wave from above, you will see something like the second.

Modulation

As everything that radiates heat, also radiates Infra-Red light. Therefore we have to take some precautions to guarantee that our IR message gets across to the receiver without errors.Modulation of the signal on a carrier frequency is the answer to make our signal stand out above the noise. With modulation we make the IR light source blink in a particular frequency. The IR receiver will be tuned to that frequency, so it can ignore everything else.

In the picture below you can see a modulated signal driving the IR LED of the transmitter on the left side. The detected signal is coming out of the receiver at the other side.

(Thanks to SBProjects.com for the gif and excellent IR resource!)

TECHNICAL DETAILS OF VS1838B IR RECEIVER

  • Model Number : VS1838B;
  • Working Voltage :2.7V to 5.5V
  • Reception Distance : 18M;
  • Reception Angle : ± 45 Degree;
  • Low Level Voltage : 0.4V
  • High Level Voltage : 4.5V;
  • Body Size : 7 x 7 x 5mm / 0.27″ x 0.27″ x 0.2″(L*W*T);
  • Pin Length : 22.5mm / 0.88″
  • Pitch : 2mm / 0.08″;

THE PINOUT FOR VS1838B IR RECEIVER:

ABOUT THE IR CONTROL

Infrared remotes are still the cheapest way to wirelessly control a device. We have designed the remote to be small, very simple, and low-cost.There are many different IR remote controls. all of these may have different encoding methods and number of physical buttons, and different codes received when a button is pressed.

Examples

READ CODES FROM IR REMOTE

This example will show you how to read IR remote codes from any IR remote using the VS1838B IR receiver and an Arduino. Once you can receive codes from individual button presses, your remote control and Arduino become a general purpose, short range, communication interface!

Connection

Build the circuit as below:

CODE PROGRAM

After above operations are completed, connect the Arduino board to your computer using the USB cable. The green power LED (labelled PWR) should go on.Open the Graphical Programming software Mixly and follow the next operations:

Drag out the IR Control block from the Communications.

Connect the IRreceive PIN to D3.

Click Save aftogramming is done. Select the board type and serial port before uploading. For instause a Uno board, just select Arduino/Genuino Uno: if you use a Mega2560, select Arduino/Genuino Mega or Mega2560.

Select the serial device of the Arduino board from the COM menu. This is likely to be COM3 or higher (COM1 and COM2 are usually reserved for hardware serial ports). To find out, you can disconnect your Arduino board and re-open the menu; the entry that disappears should be the Arduino board. Reconnect the board and select that serial port.

Next,upload the code. If the uploading fails, check and correct the code according to the prompts.

Finally, the staus will change to ‘Upload success!’.

Running Result

The sketch will automatically decode the type of remote you are using and identify which button on your remote is pressed. Open the Serial Monitor in the Mixly at 9600 bps and hit different buttons on your remote.

The Serial Monitor displaying random button presses on my remote. Different buttons show different codes:

If you use the sketch above and count the 17 buttons from left to right and top to bottom, the codes received are these: (NOTE: Receiving “FFFFFFFF” means “repeat” if you hold the button down.)

1 FFA25D
2 FF629D
3 FFE21D
4 FF22DD
5 FF02FD
6 FFC23D
7 FFE01F
8 FFA857
9 FF906F
10 FF6897
11 FF9867
12 FFB04F
13 FF18E7
14 FF10EF
15 FF38C7
16 FF5AA5
17 FF4AB5

Byamber

Graphical Programming Tutorial for Arduino – Traffic Light Controller

Introduction

The real time traffic light controller is a complex piece of equipment which consists of power cabinet, main controller or processor, relays, control panel with switches or keys, communication ports etc.

In this lesson, we will go over how to build a traffic light circuit with an arduino microcontroller.

Preparations

HARDWARE

  • Osoyoo UNO Board (Fully compatible with Arduino UNO rev.3) x 1
  • One Digit 7-Segment LED Display x 1
  • 74HC595 x 1
  • 200 ohm Resistor x 7
  • LEDs (Red LED x 2, Yellow LED x 2, Green LED x 2)
  • Breadboard x 1
  • Jumpers
  • USB Cable x 1
  • PC x 1

About this project

The use of personal vehicles is very common now a days and a result, the number of vehicles on the roads are exponentially increasing. Roads without any supervision or guidance can lead in to traffic congestions and accidents.

Traffic Lights or Traffic Signals are signalling devices that are used to control the flow of traffic. Generally, they are positioned at junctions, intersections, ‘X’ roads, pedestrian crossings etc. and alternate the priority of who has to wait and who has to go.

The traffic lights will provide instructions to the users (drivers and pedestrians) by displaying lights of standard color. The three colors used in traffic lights are Red, Yellow and Green.

In this project, an Arduino based Traffic Light Controller system is designed. It is a simple implementation of traffic lights system but can be extended to a real time system with programmable timings, pedestrian lighting etc. There is a green LED, which represents the green light. A yellow LED, which represents the yellow light. And a red LED, which represents the red light.

We will show all the hardware connections and the software needed to make this circuit work.

Connection

Build the circuit as below:

In this experiment, we use a 7-segment display to count down and set two groups of traffic lights to represent two directions, let’s say, north-south (TF1) and east-west (TF2), as shown in the above picture.

CODE PROGRAM

After above operations are completed, connect the Arduino board to your computer using the USB cable. The green power LED (labelled PWR) should go on.Open the Graphical Programming software Mixly and follow the next operations:

Setup baud rate and define datArray[] to store the to-be-display number.

Set a function State 1(), to light up a red LED(Pin 5).

Display the number from 9 to 1 on the 7-segment Display, and light up the Green2 LED (Pin 4), set T_CP( Pin 12) Low and hold low for transmitting, then pull it to save the data.

Turn off the Green LED (Pin 4), and display the number 3 to 1 on the display, then turn on Yellow 2 LED (Pin 3). Next, dim LED Yellow 2 and Red 1( Pin 5).

Next comes the State2() The blocks of State2() is just similar and you can study by yourself.

Execute function State 1() and State2().

Running Result

A few seconds after the upload finishes, you can see what is similar to the traffic light now. First, the 7-segment display counts down from 9s, and the red light in the TF1 and the green one in the TF2 light up. Then it counts down from 3, and the green LED in the TF2 goes out when the yellow lights up, with the TF1 red light still on. 3s later, the 7-segment counts down from 9s again. Meanwhile, the red light in the TF2 and the green in the TF1 light up. After 9s, it counts down from 3s, when the yellow light in the TF1 lights up and the red in the TF2 keeps on. And this repeats over and over again, as a traffic light would.

Although it is not the ideal implementation for real life scenarios, it gives an idea of the process behind the traffic light control system.

Note: The project implemented here doesn’t include the pedestrian crossing and pedestrian signaling in to consideration.

Once you know how the software operates, you can change the values to make the LEDs be on or off for any period of time. For example, instead of being on for 9 seconds, you can easily change it to 15 seconds or 30 seconds. You could make the yellow LED be on just for 1 second or 2 seconds.