- #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.