o Simple LED blinking using Arduino
Mega 2560 and Bluetooth module HC-05:
o Components:
Arduino Mega 2560 (x1)
Bluetooth Module HC-05 (x1)
LED (x3)
10-ohm Resistance (x3)
Jumper Wire (As per Required)
o Circuit Diagram:
o Connection:
Ø
Take an Arduino
Mega 2560/Uno, then take Bluetooth module HC-05.
Ø
Now connect
the VCC terminal of the HC-05 to 5V Terminal of Arduino and connect ground (GND)
terminal of HC-05 to GND terminal of Arduino.
Ø
Now connect
RXD pin of HC-05 to TX0>1 Terminal of Arduino.
Ø
Now connect
TXD pin of HC-05 to RX0>0 Terminal of Arduino.
Ø
Here we
take pin no 11,12 and 13 of Arduino as a output pin so connect 11,12 and 13 pin
with 10 ohm resistance of LED 1, LED 2 and LED 3.
Ø
Now connect
this resistance with positive (Long leg) of LED.
Ø
And finally
give common ground to all LEDs with GND terminal of Arduino.
o Program:
Ø
For
programming open the Arduino IDE software which is available on Arduino official
website.
Ø
Copy the
given program and paste it in Software then connect the Arduino with your laptop
or pc and upload the program in Arduino.
Ø
Note: To upload
the program please remove the Rx and Tx pin from Arduino board. Otherwise it
will give error while uploading.
char
junk;
String
inputString="";
void
setup() // run once,
when the sketch starts
{
Serial.begin(9600); // set the baud rate to 9600, same
should be of your Serial Monitor
pinMode(13, OUTPUT);
}
void
loop()
{
if(Serial.available()){
while(Serial.available())
{
char inChar = (char)Serial.read(); //read
the input
inputString += inChar; //make a string of the characters coming on
serial
}
Serial.println(inputString);
while (Serial.available() > 0)
{ junk = Serial.read() ; } // clear the serial buffer
if(inputString == "1"){ //in case of '1' turn the LED 1 on
digitalWrite(11, HIGH);
}else if(inputString == "0"){ //incase of '0' turn the LED 1 off
digitalWrite(11, LOW);
}
if(inputString == "2"){ //in case of '2' turn the LED 2 on
digitalWrite(12, HIGH);
}else if(inputString == "0"){ //incase of '0' turn the LED 2 off
digitalWrite(12, LOW);
}
if(inputString == "3"){ //in case of '3' turn the LED 3 on
digitalWrite(13, HIGH);
}else if(inputString == "0"){ //incase of '0' turn the LED 3 off
digitalWrite(13, LOW);
}
inputString = "";
}
}
o Working Demo:
You Can see the working Demo on my Youtube channel by searching "CreZy ElecTriCal EnGinEer"
or you can see the video by click the give link.
https://youtu.be/Wh7NqNfDV_g
or you can see the video by click the give link.
https://youtu.be/Wh7NqNfDV_g
Comments
Post a Comment