Ahmed Yassin
Published © GPL3+

Control your Light System Using Smart Phone

Now you can control your light system in your home using your smart phone by writing a character the LED turn on or turn off.

BeginnerFull instructions provided1 hour65,376
Control your Light System Using Smart Phone

Things used in this project

Story

Read more

Schematics

circuit.fzz

Code

control_light_sys

Arduino
#define CUSTOM_SETTINGS
#define INCLUDE_KEYBOARD_SHIELD

/* Include 1Sheeld library. */
#include <OneSheeld.h>

/* LEDs on pin 11,12,13 */
int ledRed    = 13;    //for Red LED
int ledYellow = 12;   //for yellow LED
int ledGreen  = 11;   //for green LED

void setup() 
{
  /* Start communication. */
  OneSheeld.begin();
  
  /* Set the LED as output. */
  pinMode(ledRed,OUTPUT);
  pinMode(ledYellow, OUTPUT);
  pinMode(ledGreen, OUTPUT);
  
  /* Keyboard callBack function. */
  AsciiKeyboard.setOnButtonChange(&keyboardFunction);
}//end of void setup

void loop()
{}

/* Function to be invoked once a new character is pressed. */
void  keyboardFunction(char data)
{
  /* Check on the incoming character. */
  if(data == 'R')
  {
    /* Turn on the LED. */
    digitalWrite(ledRed,HIGH);
  }//end of if
  else if(data=='Y')
  {
    /* Turn off the LED.*/
    digitalWrite(ledYellow,HIGH);
  }//end of else if
  else if(data == 'G')
  {
    digitalWrite(ledGreen,HIGH);
  }//end of else if
  else if(data == 'c')
  {
    digitalWrite(ledRed, LOW);
    digitalWrite(ledYellow, LOW);
    digitalWrite(ledGreen, LOW);
  } //end of els if 
  else
  {
    digitalWrite(ledRed, LOW);
    digitalWrite(ledYellow, LOW);
    digitalWrite(ledGreen, LOW);
  }//end of else
}//end of keyboard function

Credits

Ahmed Yassin

Ahmed Yassin

2 projects • 35 followers
student at Electronics & Communication Department, faculty of engineering, Zagazig University

Comments