Tech
Forums
Jobs
Books
Events
Interviews
Live
More
Learn
Training
Career
Members
Videos
News
Blogs
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
Controlling LED In Keypad App By Android App
WhatsApp
Sr Karthiga
4y
7.1k
0
2
100
Article
contolingled.zip
Introduction
In this article, I am going to explain about controlling the LED in the Keypad app by an Android app. It will be run in a real-time process for the home application.
Software Requirement
Arduino Uno
LEDs
Bread Board
Hook-Up Wires
Connection from Arduino Board to LEDs
Leds
Arduino Board
Led1
11
Led1
12
Led1
13
Led1
14
Programming
#define CUSTOM_SETTINGS
#define INCLUDE_KEYPAD_SHIELD
/* Include 1Sheeld library. */
#include <OneSheeld.h>
int
A, B, C, D;
//vaiables with names of buttons in keypad
/* A name for the LED on pin 8. */
int
yellow = 8;
/* A name for the LED on pin 9. */
int
green = 9;
/* A name for the LED on pin 10. */
int
white = 10;
/* A name for the LED on pin 11. */
int
red = 11;
void
setup()
{
/* Start communication. */
OneSheeld.begin();
/* Set LEDs as output. */
pinMode(yellow, OUTPUT);
pinMode(red, OUTPUT);
pinMode(green, OUTPUT);
pinMode(white, OUTPUT);
}
void
loop()
{
Keypad.setOnButtonChange(&lightLed);
}
void
lightLed (byte rowNumber , byte coloumnNumber)
{
/* If keypad's button A is pressed. */
if
(Keypad.isRowPressed(0) && Keypad.isColumnPressed(3))
{
A = 1;
// press A
B = 0;
C = 0;
D = 0;
}
else
if
(Keypad.isRowPressed(1) && Keypad.isColumnPressed(3))
{
A = 0;
B = 1;
// press B
C = 0;
D = 0;
}
else
if
(Keypad.isRowPressed(2) && Keypad.isColumnPressed(3))
{
A = 0;
B = 0;
C = 1;
// press c
D = 0;
}
else
if
(Keypad.isRowPressed(3) && Keypad.isColumnPressed(3))
{
A = 0;
B = 0;
C = 0;
D = 1;
// press D
}
else
{
/* Turn off all of LEDs. */
digitalWrite(yellow,LOW);
digitalWrite(green,LOW);
digitalWrite(white,LOW);
digitalWrite(red,LOW);
}
if
(A)
//press button A
digitalWrite(yellow, HIGH);
if
(B)
//press button B
digitalWrite(green, HIGH);
if
(C)
//press button C
digitalWrite(white, HIGH);
if
(D)
//press button D
digitalWrite(red, HIGH);
}
Explanation
According to the connection, upload program to the board and download the keypad app in the Playstore, install, and see the result. In the LEDs, when you press the 1 key, it is switched ON. Similarly, the other LEDs also get turned ON and OFF by the keypad app, without Bluetooth.
Output
Android App
Controlling LED
Keypad App
Up Next
Ebook Download
View all
Raspberry Pi -Sensorial Symphony of Connectivity
Read by 693 people
Download Now!
Learn
View all
Membership not found