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
  1. Arduino Uno
  2. LEDs
  3. Bread Board
  4. Hook-Up Wires
Connection from Arduino Board to LEDs
Leds Arduino Board
Led1 11
Led1 12
Led1 13
Led1 14
Programming
  1. #define CUSTOM_SETTINGS
  2. #define INCLUDE_KEYPAD_SHIELD
  3. /* Include 1Sheeld library. */
  4. #include <OneSheeld.h>
  5. int A, B, C, D; //vaiables with names of buttons in keypad
  6. /* A name for the LED on pin 8. */
  7. int yellow = 8;
  8. /* A name for the LED on pin 9. */
  9. int green = 9;
  10. /* A name for the LED on pin 10. */
  11. int white = 10;
  12. /* A name for the LED on pin 11. */
  13. int red = 11;
  14. void setup()
  15. {
  16. /* Start communication. */
  17. OneSheeld.begin();
  18. /* Set LEDs as output. */
  19. pinMode(yellow, OUTPUT);
  20. pinMode(red, OUTPUT);
  21. pinMode(green, OUTPUT);
  22. pinMode(white, OUTPUT);
  23. }
  24. void loop()
  25. {
  26. Keypad.setOnButtonChange(&lightLed);
  27. }
  28. void lightLed (byte rowNumber , byte coloumnNumber)
  29. {
  30. /* If keypad's button A is pressed. */
  31. if(Keypad.isRowPressed(0) && Keypad.isColumnPressed(3))
  32. {
  33. A = 1; // press A
  34. B = 0;
  35. C = 0;
  36. D = 0;
  37. }
  38. else if(Keypad.isRowPressed(1) && Keypad.isColumnPressed(3))
  39. {
  40. A = 0;
  41. B = 1;// press B
  42. C = 0;
  43. D = 0;
  44. }
  45. else if(Keypad.isRowPressed(2) && Keypad.isColumnPressed(3))
  46. {
  47. A = 0;
  48. B = 0;
  49. C = 1; // press c
  50. D = 0;
  51. }
  52. else if(Keypad.isRowPressed(3) && Keypad.isColumnPressed(3))
  53. {
  54. A = 0;
  55. B = 0;
  56. C = 0;
  57. D = 1; // press D
  58. }
  59. else
  60. {
  61. /* Turn off all of LEDs. */
  62. digitalWrite(yellow,LOW);
  63. digitalWrite(green,LOW);
  64. digitalWrite(white,LOW);
  65. digitalWrite(red,LOW);
  66. }
  67. if(A) //press button A
  68. digitalWrite(yellow, HIGH);
  69. if(B) //press button B
  70. digitalWrite(green, HIGH);
  71. if(C) //press button C
  72. digitalWrite(white, HIGH);
  73. if(D) //press button D
  74. digitalWrite(red, HIGH);
  75. }
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
image