I connected a bt module (Hc - 06), arduino uno and 5v module. all the connects are perfect. ie: BT module Vcc - Arduino 5v
BT module GND - Arduino GND
BT module RX - Arduino TX
BT module TX - Arduino RX
Relay module (connected with seperate 5v supply) signal pin - Arduino pin 3

When i programmed the following code into the arduino:

const int relayPin = 3; // Relay signal pin to arduino digital pin 3

int state; // State will store income data from serial port
int flag; // Flag variable will help us to control on/off function with only one command :wink:

void setup()
pinMode(relayPin, OUTPUT); // Set relay pin (3) as output
Serial.begin(9600); // Initialize serial communication at 9600 bits per second

void loop()
if(Serial.available() > 0){
state =; // Save income data to variable ‘state’

//If state is equal with letter ‘W’, turn leds on or of off
if (state == ‘W’) {
if (flag==0){
digitalWrite(relayPin, HIGH);
else if (flag==1){
digitalWrite(relayPin, LOW);
delay(200); // Small delay…

When i connect the BT with my mobile and try to control the relay with the application (that sends letter “W”) nothing happens? IS something wrong with my arduino or BT module?

Everybody want s HELP. 1) please give your post a better title 2) please follow posting guidelines and use code tags. 3) Please post the schematic of your project as that can be part of the problem.

Do you see the RX LED blink when you send the 'W'? If not you may not have the bluetooth module set up correctly.

You might want to have the built in LED (Pin 13) follow the relay output so you can see if maybe the software is working but the relay isn't switching.

nope. it doesn't blinks when i enter the command W. how should i set the bt module then. plus the relay is working i tried switching it on off without the bt i.e with delay commands.,148850.0.html

item #6

and item #7