Posted by AlexMn42 on Sep 21, 2017

Control your Light System Using Smart Phone

The project idea is to proof that you can control your home lighting system using only your smart phone, so the LEDs in the project represents different systems in our home as an example.

All you need for the project:

1- 1sheeld

2- Arduino Uno

3- LEDs

4- Jumbers

#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
Please follow and like us:
Post a Comment

Leave a Reply

Translate »
%d bloggers like this: