You may now use your smartphone to manage your home’s light system by writing a character to switch on or off the LEDs.
The goal of the project is to prove that you can manage the light system in your home using only your smartphone, so the LEDs in the project are meant to encode the different systems in our house.
All you need for Light System:
then connect the circuit as shown below:
First, let’s know more about 1sheeld:
1Sheeld turns your smartphone into 40 different Arduino shields. So we don’t have to buy shields for Arduino as we have them in our smartphones.
How to use 1sheeld?
Stack 1Sheeld on top of your Arduino board, and write the code using the 1Sheeld library. Pair 1Sheeld board with 1Sheeld app over Bluetooth. Select the shields from a list of over 40 shields.
for more information about 1sheeld and how to use shields follow this link
http://1sheeld.com/tutorials/getting-started/
Let’s back to our project
Open 1sheeld app and connect the app with your 1sheeld then open “keyboard” shield.
Press ‘R‘ Red LED will turn on :
Press ‘Y‘ Yellow LED will turn on:
Press ‘G‘ Green LED will turn on:
and finally to turn off all press ‘C’
Code Control Light System 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