0

members

Difficult Basics: Project 022u 4x3 matrix membrane keypad, LEDs, active piezo buzzer, LCD1602 I2C, relay servo

of Acoptex.com in UNO

Basics: Project 022u

Project name:  4x3 matrix membrane keypad, LEDs, active piezo buzzer, LCD1602 I2C, 5v relay module, 5V servo motor - security system

Attachments: sketch1, sketch2, sketch3 and libraries1pitches.hlibraries2

WARNING – THIS PROJECT INVOLVES HIGH VOLTAGES THAT CAN CAUSE SERIOUS INJURY OR DEATH. PLEASE TAKE ALL NECESSARY PRECAUTIONS, AND TURN OFF ALL POWER TO A CIRCUIT BEFORE WORKING ON IT. WE ARE NOT RESPONSIBLE FOR ANY DAMAGE, INJURY, DEATH AND OTHER THINGS CAUSED BY THIS PROJECT IMPLEMENTATION. 

In this project, you need these parts :

1.Aruduino Uno R3 (you can also use the other version of Arduino)

2. 4 x 3 matrix membrane keypad 1pc

3.Arduino IDE ( you can download it from here  )

4.Jumper cables

5.Breadboard 1 pc

6.LEDs 2 pcs (red and green colors)

7.Resistor 2 pcs (220 Ohm each)

8. Active piezo buzzer 1 pc

9. LCD 1602 I2C module 1 pc

10. DC 5V relay module 1 pc

11. DC 5V MG91 or SG90 Micro Servo Motor 1 pc

or

General

We will learn how to connect  4 x 3 matrix membrane keypad, LEDs, active piezo buzzer, LCD1602 I2C module, DC 5V servo motor and DC 5V relay module to Arduino board and upload the security code to it.

Understanding the servo motor

You can read more about it here.

Understanding the DC 5V relay module

You can read more about it here.

Understanding the piezo buzzer

You can read more about it here.

Understanding the 4x3 matrix membrane keypad

Keypads are used in all types of devices, including cell phones, fax machines, microwaves, ovens, door locks, etc. They're practically everywhere.

For this project, the type of keypad we will use is a 4 x 3 membrane matrix keypad. This is a keypad that follows an encoding scheme that allows it to have much less output pins than there are keys. For example, the matrix keypad we are using has 12 keys (0-9, *, #), yet only 7 output pins. With a linear keypad, there would have to be 17 output pins (one for each key and a ground pin) in order to work. The matrix encoding scheme allows for less output pins and thus much less connections that have to made for the keypad to work. In this way, they are more efficient than linear keypads, being that they have less wiring. 

Understanding LCD 1602 I2C module

The meaning of LCD1602 marking is Liquid Cristal Display 16 characters by 2 rows, each row displays 16 characters of either 5x7 or 5x8 dot matrix characters.The LCD is available in a 16 pin package. It consists of back light and contrast adjustment function and each dot matrix has 5×8 dot resolution

As we all know, though LCD and some other displays greatly enrich the man-machine interaction, they share a common weakness. When they are connected to a controller, multiple IOs will be occupied of the controller which has no so many outer ports. Also it restricts other functions of the controller. Therefore, LCD1602 with an I2C bus is developed to solve the problem.I2C bus is a type of serial bus invented by PHILIPS. It is a high performance serial bus which has bus ruling and high or low speed device synchronization function required by multiple-host system. The blue potentiometer on the I2C LCD1602 (see the figure below) is used to adjust the backlight  for better display. I²C uses only two bidirectional open-drain lines, Serial Data Line (SDA) and Serial Clock Line (SCL), pulled up with resistors. Typical voltages used are +5 V or +3.3 V although systems with other voltages are permitted.

Datasheet can be found here.

Signals and connections of servo motors


Signals and connections of active piezo buzzer.

Active piezo buzzer pin marked with (+) sign should be connected to Arduino Uno board digital pin which sends a signal, the other pin of active piezo buzzer should be connected to Arduino Uno board GND.

Signals and contacts of LCD 1602 I2C module

As you can see on the back of LCD 1602 module there 4 connections: GND (-), VCC (+5V), Serial Data Line (SDA),(Arduino SDA pin or analog pin A4)  and Serial Clock Line (SCL) (Arduino SCL pin or analog pin A5).

Signals and connections of 4x3 matrix membrane keypad

Signals and connections of DC 5V relay module

The SRD-05 VDC-SL-C relay has three high voltage terminals (NC, C, and NO) which connect to the device you want to control. The other side has three low voltage pins (Ground, Vcc, and Signal) which connect to the Arduino.

NC: Normally closed 120-240V terminal
NO: Normally open 120-240V terminal
C: Common terminal

 

Signals and connections of LED

The operating voltage of the LED is 1.8V and the operating current is 10mA-20mA. The Arduino Uno board can supply 5V or 3.3V power. We will use 5V for this project, so the minimum resistance of the current limiting resistor should be (5 V to 1.8 V)/20 = 160 Om. The 220 Om offered in the kit is suitable and you can also choose other resistors that meet the condition. The larger the resistance is, the dimmer the LED will get.

Signals and connections of active piezo buzzer

Active piezo buzzer pin marked with (+) sign should be connected to Arduino Uno board digital pin which sends a signal, the other pin of active piezo buzzer should be connected to Arduino Uno board GND.

Wiring

WARNING – THIS PROJECT INVOLVES HIGH VOLTAGES THAT CAN CAUSE SERIOUS INJURY OR DEATH. PLEASE TAKE ALL NECESSARY PRECAUTIONS, AND TURN OFF ALL POWER TO A CIRCUIT BEFORE WORKING ON IT. WE ARE NOT RESPONSIBLE FOR ANY DAMAGE, INJURY, DEATH AND OTHER THINGS CAUSED BY THIS PROJECT IMPLEMENTATION. 

It can be a powerful light or other equipment connected to 5V relay.The relay has two different types of electrical contacts inside – normally open (NO) and normally closed (NC). The one you use will depend on whether you want the 5V signal to turn the switch on or turn the switch off. The 120-240V supply current enters the relay at the common (C) terminal in both configurations. To use the normally open contacts, use the NO terminal. To use the normally closed contacts, use the NC terminal.We will use NO (Normally open)configuration, when the relay receives a HIGH signal the 120-240V switch closes and allows current to flow from the C terminal to the NO terminal. A LOW signal deactivates the relay and stops the current. So if you want the HIGH signal to turn ON the relay, use the normally open terminal.

Make sure that the high voltage connections to the 5V relay module are very well secured. Identify the hot power wire (red wire in the diagram above) in the cord leading to the light bulb and make a cut. Connect the side leading to the light bulb to the NO terminal of the 5V relay, and the side leading to the plug to the C terminal. This way the relay is on the hot side, and current is switched before it reaches the light bulb. It’s dangerous to put the relay on the neutral wire, since if the device fails current can still fault to ground when the relay is off.

The following picture shows the needed connections with the Arduino Uno

Step by Step instruction

  1. Open Arduino IDE.
  2. Plug your Adruino Uno board into your PC and select the correct board and com port
  3. Open up serial monitor and set your baud to 9600 baud.
  4. Find your I2C address. Each device has an I2C address that it uses to  accept commands or send messages. Load the sketch over at http://playground.arduino.cc/Main/I2cScanner and follow the instructions to use it.  By opening up the Serial monitor window after you upload the sketch, Arduino will scan the address range looking for a reply.  Even though the documentation said it was 0x27, this scanner can detect different (in my case 0x3F).
  5. Modify the sketch in attachments above (you can use the sketch below too): the line LiquidCrystal_I2Clcd(0x3F, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE) (See part marked bold).
  6. Verify and upload the the sketch to your Adruino Uno.
  7. Press any of the buttons on the keypad.
  8. This sketch takes input from a keypad for secret code.  If the code is entered correctly it turns on a green LED to simulate access granted and prints access granted in Serial Monitor and on LCD screen. Otherwise the red LED is lit and access denied is printed in Serial Monitor and on LCD screen. Active piezo buzzer will sound different melody in each case. DC 5V relay module connected as NO - it will turn on equipment connected to it.Servo motor will turn to 90 degrees (you can easily adjust that but do not forget to change servo motor default position in void setup () too.

Summary

We have learnt how to connect 4x3 matrix membrane keypad, LEDs, active piezo buzzer, LCD1602 I2C module, DC 5V relay module and DC 5V servo motor  to Arduino board and uploaded the security code to it.

Libraries:

  • See attachments on the begining of this project description.
  • We have used the library - NewliquidCrystal_1.3.4.zip which we downloaded, unzipped, changed the name of folder to LiquidCristal and added to libraries in our PC, for example C:\Users\toshiba\Documents\Arduino\libraries. This link you can find in Preferences of Adruino IDE program which installed in your PC.
  • If you have LiquidCristal folder in this location already - delete this folder and copy folder, which was made by you, to this location.
  • pitches.h file contains all the pitch values for typical notes. For example, NOTE_C4 is middle C. NOTE_FS4 is F sharp, and so forth. This note table was originally written by Brett Hagman, on whose work the tone() command was based. You may find it useful for whenever you want to make musical notes.File should be in the same directory with sketch.
  • We have attached the Keypad library but you can also download and install it via the Arduino IDE library manager. If you wanna use our library then download, unzip it and add to libraries in your PC, for example C:\Users\toshiba\Documents\Arduino\libraries or C:\Program Files (x86)\Arduino\libraries. This link you can find in Preferences of Adruino IDE program which installed in your PC.
  • Servo library included in Arduino IDE.
  • Keypad library is available via the Arduino IDE library manager. Open Arduino IDE, then Sketch->Include Library->Manage Libraries... Then search for Keypad. Once found, click on its entry and the install button will appear. See more information about this library here.
  • EEPROM library is integrated inside Arduino IDE. We also attached it here.
  • Password library we attached too. Download, unzip it and add to libraries in your PC, for example C:\Users\toshiba\Documents\Arduino\libraries or C:\Program Files (x86)\Arduino\libraries. This link you can find in Preferences of Adruino IDE program which installed in your PC.

Sketch:

  • See attachments on the begining of this project description.
  • There are 3 different sketches. Sketch1 /Andrew Mascolo idea/ has default password inserted in code which you can change to yours easily+you can use different password lenght.
  • Sketch2 /Saddam idea/ has default password programmed in code which you can change to yours easily by pressing # on keypad + you can modify code and use different password lenght.
  • Sketch3 max password lenght is 20. when you enter secret code press * to enter. it will check if code is wrong or good. Password you can modify on the begining of the code.


Other projects of Acoptex.com
Medium Basics: Project 083w Sipeed Maixduino board - Using PlatformIO IDE of Acoptex.com in Sipeed Maixduino 08-08-2019

« Go back to category
Is this project fake? Report it!   
Recommend to a friend
Published at 20-09-2017
Viewed: 420 times