Introduction
In this article, I am going to explain about controlling the LED in 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 <OneSheeld.h>
- int A, B, C, D;
-
- int yellow = 8;
-
- int green = 9;
-
- int white = 10;
-
- int red = 11;
-
- void setup()
- {
-
- OneSheeld.begin();
-
- 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.isRowPressed(0) && Keypad.isColumnPressed(3))
- {
- A = 1;
- B = 0;
- C = 0;
- D = 0;
- }
-
- else if(Keypad.isRowPressed(1) && Keypad.isColumnPressed(3))
- {
- A = 0;
- B = 1;
- C = 0;
- D = 0;
- }
-
- else if(Keypad.isRowPressed(2) && Keypad.isColumnPressed(3))
- {
- A = 0;
- B = 0;
- C = 1;
- D = 0;
- }
-
- else if(Keypad.isRowPressed(3) && Keypad.isColumnPressed(3))
- {
- A = 0;
- B = 0;
- C = 0;
- D = 1;
- }
- else
- {
-
- digitalWrite(yellow,LOW);
- digitalWrite(green,LOW);
- digitalWrite(white,LOW);
- digitalWrite(red,LOW);
- }
- if(A)
- digitalWrite(yellow, HIGH);
- if(B)
- digitalWrite(green, HIGH);
- if(C)
- digitalWrite(white, HIGH);
- if(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