Control Relay By Matrix Keyboard

Control Relay By Matrix Keyboard

Today, in this experiment, we do a keyboard control relay opening and closing.Press the keys 1 to 8 to control 8 relays separately.Press the key 0 to turn off the 8-way relay.
– 1 * Adeept 2560 Board
– 1 * 8 Channel Relay Module
– 1 *  4*4 Matrix Keyboard
– 8 * Male To Male Jumper Wires
– 8 * Male To Female Jumper Wires

Experimental Principle 
In order to save the resources of the microcontroller port, we usually connect the buttons of the matrix in an actual project.
The following is the schematics of 4×4 matrix keyboard:

In this tutorial, we use the ‘Keypad’ function library. Before programming, please install the library.

This is a 5V 8-channel replay interface board which is able to control various appliance, and other equipments with large current. It can be controlled directly by Microcontroller(Arduino,8051,AVR,PIC,DSP,ARM,MSP430,TTL logic). 5V 8-Channel reply, interface board, and each one needs 15-20mA driver current. It is equipped with high-current relay AC250V 10A also DC30V 10A and screw holes for easy installation.

Experimental Procedures
Step 1: Build the circuit

Step 2: Program controlRelayByMatrixKeyboard.ino

Keypad Library Link:Keypad

File name: controlRelayByMatrixKeyboard.ino

Author: Tom
Date: 2017/03/14 
#include <Keypad.h>
const byte ROWS = 4; //four rows
const byte COLS = 4; //four columns
//define the cymbols on the buttons of the keypads
char hexaKeys[ROWS][COLS] = {
byte rowPins[ROWS] = {9, 8, 7, 6}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {5, 4, 3, 2}; //connect to the column pinouts of the keypad
//initialize an instance of class NewKeypad
Keypad customKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS); 

const int relayPin1 = 14;
const int relayPin2 = 15;
const int relayPin3 = 16; 
const int relayPin4 = 17; 
const int relayPin5 = 18; 
const int relayPin6 = 19; 
const int relayPin7 = 20; 
const int relayPin8 = 21; 
void setup(){
  Serial.begin(9600);//Open serial
  pinMode(relayPin1, OUTPUT); //initialize the relayPin as an output
  pinMode(relayPin2, OUTPUT); //initialize the relayPin as an output
  pinMode(relayPin3, OUTPUT); //initialize the relayPin as an output
  pinMode(relayPin4, OUTPUT); //initialize the relayPin as an output
  pinMode(relayPin5, OUTPUT); //initialize the relayPin as an output
  pinMode(relayPin6, OUTPUT); //initialize the relayPin as an output
  pinMode(relayPin7, OUTPUT); //initialize the relayPin as an output
  pinMode(relayPin8, OUTPUT); //initialize the relayPin as an output
void loop(){
  char customKey = customKeypad.getKey();//Read Key data   
  if (customKey){
    Serial.println(customKey);          //send the key data by serial port (UART)
    case '0':
          digitalWrite(relayPin1, LOW); //drive relay closure conduction
          digitalWrite(relayPin2, LOW); //drive relay closure conduction
          digitalWrite(relayPin3, LOW); //drive relay closure conduction
          digitalWrite(relayPin4, LOW); //drive relay closure conduction
          digitalWrite(relayPin5, LOW); //drive relay closure conduction
          digitalWrite(relayPin6, LOW); //drive relay closure conduction
          digitalWrite(relayPin7, LOW); //drive relay closure conduction
          digitalWrite(relayPin8, LOW); //drive relay closure conduction
    case '1':
          digitalWrite(relayPin1, HIGH); //drive relay closure conduction
    case '2':
          digitalWrite(relayPin2, HIGH); //drive relay closure conduction
    case '3':
          digitalWrite(relayPin3, HIGH); //drive relay closure conduction
    case '4':
          digitalWrite(relayPin4, HIGH); //drive relay closure conduction
    case '5':
          digitalWrite(relayPin5, HIGH); //drive relay closure conduction
    case '6':
          digitalWrite(relayPin6, HIGH); //drive relay closure conduction
    case '7':
          digitalWrite(relayPin7, HIGH); //drive relay closure conduction
    case '8':
          digitalWrite(relayPin8, HIGH); //drive relay closure conduction
    default: break;   

Step 3: Compile and download the sketch to the UNO R3 board.

50 Replies to “Control Relay By Matrix Keyboard”

  1. Here at Leslie’s Pugsland Breeder, Our beautiful fawn pug has given birth to 4 healthy Pug puppies.
    She is our beloved family dog and this is her 1st litter.
    Both mum and dad are AKC registered with 5 gen pedigree certificate. Both from Top Champion bloodlines.Mum and Dad can be seen. Puppies have been wormed weeks 2,4,6,8 and will have had a flea preventative treatment before leaving us.
    They will have their vet check, 1st vaccinations and microchip.
    To view all available puppies and recent pictures, Search us in google as LESLIE’S PUGSLAND BREEDER or click on our website link bellow :
    Pug Puppies for sale | pug for sale near me | pug puppy for sale | pug puppy | pug for sale | pug puppies for sale in va | black pug puppies for sale

  2. Pingback: buy weed online
  3. Pingback: Cirro Energy
  4. Pingback: CBD Spray
  5. Pingback: Whois Lookup
  6. Pingback: uniccshop
  7. Pingback: What is CBD
  8. Pingback: دردشة
  9. Pingback: Webpage
  10. Pingback: How to lose weight
  11. Pingback: سایت پوکر
  12. Pingback:
  13. Pingback: 안전바카라
  14. Pingback: influens me
  15. Pingback: Dukan Diet
  16. Pingback: tai game soc dia
  17. Pingback: Attitude Seeds
  18. Pingback: open my profile
  19. Pingback: chatte
  20. Pingback: buy bud online
  21. Pingback: gclub
  22. Pingback: poker iranian
  23. Pingback: Mallorca Arbeit
  24. Pingback: Bitcoin Phishing
  25. Pingback: tambah followers
  26. Pingback: seo agency
  27. Pingback: Boiler repair

Leave a Reply