LED Intensity With Arduino and PC

by cartonerdd in Circuits > Arduino

2763 Views, 28 Favorites, 0 Comments

LED Intensity With Arduino and PC

20160111_221330.jpg

An Arduino UNO board will be used to vary the intensity of an ultrabright LED. The communication with the arduino will be via Bluetooth, using a PC to send the instructions

Sketch and Design of the Circuit

blue_8.JPG
blue_7.JPG

The used materials are:

- Arduino UNO board

- Breadboard

- Ultra bright LED and resistor (330 Ohms)

- Bluetooth module (HC-05)

- 2 Power sources (4 AA cases)

- Cabels

The sketck shows how will be connected the module, the power source, the LED and the resistor. The simulation of the design gives a better overview of how it will look the final circuit.

The Bluetooth Module (HC-05)

Blue_9.JPG

The HC-05 has 6 pins, however, only 4 will be connected in this proyect. According to he desing in the previous step, here is show with coloured arrows the needed connections. RX and TX are the receive and transmit pins respectively. Here I briefly descrive the connection of the RX and TX pins in the circuit:

- RX (HC-05) ==> connected to the TX of the Arduino

- TX (HC-05) ==> connected to the RX of the Arduino

PC Bluetooth Communication

blue_10.JPG

Wenn the HC-05 is for the first time connected to the PC, this one must first find, recognice and connect to the HC-05 module, this is called pairing. Using a Toshiba PC, the picture shows the Bluetooth assitant window. When the connection is performed, the simbol of the HC-05 in the PC will change.

Programming the Communication

In this step, the written programm is shown. The instructions will be given using the PC and wenn an instruction is received by the Arduino, this one will send a confirmation to the PC, this in order to know in real time if the commans where successfully sended.

// The program is designed to perform the next tasks:

// 1. a LED will be remoted controlled via Bluetooth

// 2. Intensity of the light will increase

// 3. Will be controlled using the Bluetooth module from a PC

// Written by Alberto Morales San Juan

#include // serial communication library

SoftwareSerial ConfigurePorts (8, 9); // Port_8 ==> RX, Port_9 ==> TX

int ReceiveInfo; // for the received information

int LED_Signal=11

; // Port 13 for the dc motor

void setup()

{

ConfigurePorts.begin(9600);

ConfigurePorts.println("LED intensity from 0 % to 94 %");

pinMode(LED_Signal, OUTPUT);

}

void loop()

{

if(ConfigurePorts.available()>0) {

ReceiveInfo=ConfigurePorts.read();

if(ReceiveInfo=='0') { // LED 0 %

analogWrite(LED_Signal,0);

ConfigurePorts.println("LED 0 %");

}

if(ReceiveInfo=='1') { // LED 16 %

analogWrite(LED_Signal,40);

ConfigurePorts.println("LED 16 %");

}

if(ReceiveInfo=='2') { // LED 31 %

analogWrite(LED_Signal,80);

ConfigurePorts.println("LED 31 %");

}

if(ReceiveInfo=='3') { // LED 47 %

analogWrite(LED_Signal,120);

ConfigurePorts.println("LED 47 %");

}

if(ReceiveInfo=='4') { // LED 63 %

analogWrite(LED_Signal,160);

ConfigurePorts.println("LED 63 %");

}

if(ReceiveInfo=='5') { // LED 78 %

analogWrite(LED_Signal,200);

ConfigurePorts.println("LED 78 %");

}

if(ReceiveInfo=='6') { // LED 94 %

analogWrite(LED_Signal,240);

ConfigurePorts.println("LED 94 %");

}

}

}

Serial Port (Virtual Terminal)

blue_6.JPG
blue_4.JPG
blue_5.JPG

After pairing the HC-05 with the PC, a virtual terminal is required in order to send and visualize the commands given to the Arduino. The selecte software is Tera Term. This programm allows to select the port for communication and visualize the sended commands and watch the received comments. In this case, the COM40 is attachet to the HC-05. In the picture can be seen, that wenn an instruction is given, the comments are received in the virtual terminal. In this case, the comments indicate the percentage of intensity of the LED.

Wiring and Testing

20160111_221334.jpg
LED intensity control via PC with Bluetooth

Now that the circuit is finished, the communication achieved and the required sofware installed (the virtual terminal, Tera Term), the test phase can be performed. The video shows the how the intensity of the LED vary according to the given instructions from the PC. Thansk for reading.