Hardware required
- Arduino uno-1 pcs.
- Android phone or Tablet.
- Bluetooth adapter HC 06-1pcs.
- LEDs - 3 nos.
- Jumper wires - 7 nos.
Project description
I am going to control 3 LEDs by using a mobile phone which is running in Android OS. Here, i am using android phone as remote to control led. I can switch on and switch off light and control the brightness of one led also. I made android app by MIT app inventor. You can download android app by searching "light" in MIT app inventor gallery after log on to this site or you can download by link https://drive.google.com/file/d/0B_w5O5-1CXjJU3hCcHoyempBREk/view?usp=sharing.
For installing this app, don't forget to enable phone to install app from Unknown sources. For this go to Settings~Security~Unknown sources and enable Allow installation of apps from unknown sources
For installing this app, don't forget to enable phone to install app from Unknown sources. For this go to Settings~Security~Unknown sources and enable Allow installation of apps from unknown sources
Circuit Diagram
HC06 Connection
Connect Vcc of HC06 to +5v of Arduino.
Connect Gnd of HC06 to Gnd of Arduino.
Connect Tx of HC06 to pin 10 of arduino.
Connect Rx of HC06 to pin 11 of arduino.
Video
Arduino Script
#include <SoftwareSerial.h>
SoftwareSerial Bt(10,11);//Rx of HC06 to 11 & Tx to 10
int val;
// recieving value as intiger from HC06 bluetooth device
void setup()
{
Bt.begin(9600);
pinMode(7,OUTPUT);//pin 7,8 & 9 as output
pinMode(8,OUTPUT);
pinMode(9,OUTPUT);//pin 9 is also using as PWM output to //controll brightness
}
void loop()
{
if(Bt.available()>0)
{
val=Bt.read();
}
if(val>100)
{
switch(val)
{
case 101:
{
digitalWrite(7,1);
break;
}
case 102:
{
digitalWrite(7,0);
break;
}
case 103:
{
digitalWrite(8,1);
break;
}
case 104:
{
digitalWrite(8,0);
break;
}
case 105:
{
digitalWrite(9,1);
break;
}
case 106:
{
digitalWrite(9,0);
break;
}
case 107:
{
digitalWrite(7,1);
digitalWrite(8,1);
digitalWrite(9,1);
break;
}
case 108:
{
digitalWrite(7,0);
digitalWrite(8,0);
digitalWrite(9,0);
break;
}
}
}
else
{
//maping value to 0 to 255 from 0 to 255
int mod_val=map(val,0,100,0,255);
analogWrite(9,mod_val);
}
}
SoftwareSerial Bt(10,11);//Rx of HC06 to 11 & Tx to 10
int val;
// recieving value as intiger from HC06 bluetooth device
void setup()
{
Bt.begin(9600);
pinMode(7,OUTPUT);//pin 7,8 & 9 as output
pinMode(8,OUTPUT);
pinMode(9,OUTPUT);//pin 9 is also using as PWM output to //controll brightness
}
void loop()
{
if(Bt.available()>0)
{
val=Bt.read();
}
if(val>100)
{
switch(val)
{
case 101:
{
digitalWrite(7,1);
break;
}
case 102:
{
digitalWrite(7,0);
break;
}
case 103:
{
digitalWrite(8,1);
break;
}
case 104:
{
digitalWrite(8,0);
break;
}
case 105:
{
digitalWrite(9,1);
break;
}
case 106:
{
digitalWrite(9,0);
break;
}
case 107:
{
digitalWrite(7,1);
digitalWrite(8,1);
digitalWrite(9,1);
break;
}
case 108:
{
digitalWrite(7,0);
digitalWrite(8,0);
digitalWrite(9,0);
break;
}
}
}
else
{
//maping value to 0 to 255 from 0 to 255
int mod_val=map(val,0,100,0,255);
analogWrite(9,mod_val);
}
}