Project showcase
Bluetooth Controlled Light Switch

Bluetooth Controlled Light Switch

Don't stumble around looking for the light switch, turn it on before you walk inside using a bluetooth-enabled android phone!

  • 23,398 views
  • 4 comments
  • 26 respects

Components and supplies

Texas instruments l293dne image
Texas Instruments Dual H-Bridge motor drivers L293D
×1
Servos (Tower Pro MG996R)
Hitec HS-311 modified to DC
×1
61pby065esl  sx679  tnr8syww5d
HC-05 Bluetooth Module
×1
A000066 iso both
Arduino UNO & Genuino UNO
×1
11026 02
Jumper wires (generic)
×1
12002 04
Breadboard (generic)
×1
Mounting Hardware
Screws, drywall anchors, zip ties, aluminum sheet metal, rubber bands
×1
1434509556 android phone color
Android device
×1

Necessary tools and machines

Drill Press
Used the one in the Junior Design Lab, brought my own bits

Apps and online services

BlueTerm
android app

About this project

Do you get home from work after dark? Are you tired of stumbling around looking for your poorly-placed light switch? Are you just too lazy to get out of bed and turn the lights off before you go to sleep? We've built a Bluetooth based project that signals an Arduino to power a DC motor to flick your light switch off or on. All you have to do is bolt it to the wall next to almost any switch, and control it with your android phone!

When you connect to the device via any Arduino Bluetooth app, you send signals to the controller using your phones keypad. Sending a number 1 flicks the lights on, and sending a number 2 flicks them off. The 180 degree servo used is a hitec-311 gear motor. We converted the motor to DC for ease of directional control with the stepper motor driver.

Demo Video


Code

Arduino Bluetooth Motor controller codeC/C++
It's an arduino .ino file. You upload it to an arduino.
int motorPin1 = 3; // pin 2 on L293D 
int motorPin2 = 4; // pin 7 on L293D 
int enablePin = 5; // pin 1 on L293D 
int state;
int flag=0;        //makes sure that the serial only prints once the state

void setup() {
    // sets the pins as outputs:
    pinMode(motorPin1, OUTPUT);
    pinMode(motorPin2, OUTPUT);
    pinMode(enablePin, OUTPUT);
    // sets enablePin high so that motor can turn on:
    digitalWrite(enablePin, HIGH);

    Serial.begin(9600);
}

void loop() {
    //if some date is sent, reads it and saves in state
    if(Serial.available() > 0){     
      state = Serial.read();   
      flag=0;
    }   
    // if the state is '0' the DC motor will turn off
    if (state == '0') {
        digitalWrite(motorPin1, LOW); // set pin 2 on L293D low
        digitalWrite(motorPin2, LOW); // set pin 7 on L293D low
        if(flag == 0){
          Serial.println("Motor: off");
          flag=1;
        }
    }
    // if the state is '1' the motor will turn right
    else if (state == '1') {
        digitalWrite(motorPin1, LOW); // set pin 2 on L293D low
        digitalWrite(motorPin2, HIGH); // set pin 7 on L293D high
        if(flag == 0){
          Serial.println("Motor: right");
          flag=1;
        }
    }
    // if the state is '2' the motor will turn left
    else if (state == '2') {
        digitalWrite(motorPin1, HIGH); // set pin 2 on L293D high
        digitalWrite(motorPin2, LOW); // set pin 7 on L293D low
        if(flag == 0){
          Serial.println("Motor: left");
          flag=1;
        }
    }
}

Schematics

Schematic
Arduino, bluetooth module, servo amplifier, and 9v battery connection diagram
Schematic

Comments

Team The Instrumentation Crustaceans

Hqdefault
Trevor Rusin
  • 1 project
  • 1 follower
Golf gt
James Tyler Myers
  • 1 project
  • 0 followers
Uncc
Mike Dumaine
  • 1 project
  • 0 followers

Additional contributors

  • Circuit design and assembly, coding by Tyler Myers
  • Parts provider, troubleshooting, coding by Michael Dumaine

Published on

May 4, 2016

Members who respect this project

Default10487434 10101544397202548 602652689234148955 n1112DefaultVel logo 400DefaultPhotoDefault

and 18 others

See similar projects
you might like

Similar projects you might like

Locks controlled via bluetooth

Project in progress by FabLab SPQwoRk

  • 1,940 views
  • 2 comments
  • 12 respects

Bluetooth Controlled Servo

Project tutorial by JANAK13

  • 2,826 views
  • 11 comments
  • 19 respects

Bluetooth Controlled Car

Project tutorial by JANAK13

  • 2,289 views
  • 7 comments
  • 15 respects

How to control your light switch from your smartphone?

Project in progress by Mahmoud Ahmed

  • 22,680 views
  • 3 comments
  • 15 respects

Bluetooth Mini Car

Project showcase by Hesham

  • 8,449 views
  • 2 comments
  • 32 respects

Remote Bluetooth Light Control with Python

Project showcase by Noah Huber-Feely

  • 6,269 views
  • 0 comments
  • 12 respects
Add projectSign up / Login