Wiring and coding help

I'm looking for help making a wiring diagram for a Arduino nano that connects a PIR motion sensor, 4X4 Keypad, Buzzer and Lcd1603 (All items from the "The most complete super starter kit" (Except for the nano)). I have tried making it with a 595 shift register and connecting the 4X4 keypad but it did not work. Also, can someone share a simple piece of code that prints the keypad button pressed to the lcd screen (and if motion is detected have the buzzer make a short beep)?

How many pins does the LCD screen use ?

The LCD pins are:
VSS,VDD,VO,RS,RW,E,D0,D1,D2,D3,D4,D5,D6,D7,A,K

OK, but how many of them are actually used ?

Are there any examples of using it in the starter kit instructions ?

I have been using the Schematic on this page as a guide.
https://docs.arduino.cc/learn/electronics/lcd-displays/
According to it you need to use 12 out of the 16 pins, with 6 of those needing to be digital pins.

FIrst things first.

Start with just the LCD. Can that be connected and shown to work, with the code as listed?

Then, add the keypad, using 4 digital pins and 4 analog pins. You should be able to generate a button value, just throw it in R1C1 of the LCD.
Now, add the PIR and Buzzer.

Doing it all at once is like learning to talk, drive, and cook all at once - your odds of success are low.

How many pins does this example from that page yse ?

/*
  LiquidCrystal Library - Hello World

 Demonstrates the use a 16x2 LCD display.  The LiquidCrystal
 library works with all LCD displays that are compatible with the
 Hitachi HD44780 driver. There are many of them out there, and you
 can usually tell them by the 16-pin interface.

 This sketch prints "Hello World!" to the LCD
 and shows the time.

  The circuit:
 * LCD RS pin to digital pin 12
 * LCD Enable pin to digital pin 11
 * LCD D4 pin to digital pin 5
 * LCD D5 pin to digital pin 4
 * LCD D6 pin to digital pin 3
 * LCD D7 pin to digital pin 2
 * LCD R/W pin to ground
 * LCD VSS pin to ground
 * LCD VCC pin to 5V
 * 10K resistor:
 * ends to +5V and ground
 * wiper to LCD VO pin (pin 3)

 Library originally added 18 Apr 2008
 by David A. Mellis
 library modified 5 Jul 2009
 by Limor Fried (http://www.ladyada.net)
 example added 9 Jul 2009
 by Tom Igoe
 modified 22 Nov 2010
 by Tom Igoe
 modified 7 Nov 2016
 by Arturo Guadalupi

 This example code is in the public domain.

 https://docs.arduino.cc/learn/electronics/lcd-displays

*/

// include the library code:
#include <LiquidCrystal.h>

// initialize the library by associating any needed LCD interface pin
// with the arduino pin number it is connected to
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

void setup() {
  // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
  // Print a message to the LCD.
  lcd.print("hello, world!");
}

void loop() {
  // set the cursor to column 0, line 1
  // (note: line 1 is the second row, since counting begins with 0):
  lcd.setCursor(0, 1);
  // print the number of seconds since reset:
  lcd.print(millis() / 1000);
}

Here is just the LCD module. when ran I can see the text on the screen. Is there any way to simplify the wiring?

/*
  LiquidCrystal Library - Hello World

 Demonstrates the use a 16x2 LCD display.  The LiquidCrystal
 library works with all LCD displays that are compatible with the
 Hitachi HD44780 driver. There are many of them out there, and you
 can usually tell them by the 16-pin interface.

 This sketch prints "Hello World!" to the LCD
 and shows the time.

  The circuit:
 * LCD RS pin to digital pin 12
 * LCD Enable pin to digital pin 11
 * LCD D4 pin to digital pin 5
 * LCD D5 pin to digital pin 4
 * LCD D6 pin to digital pin 3
 * LCD D7 pin to digital pin 2
 * LCD R/W pin to ground
 * LCD VSS pin to ground
 * LCD VCC pin to 5V
 * 10K resistor:
 * ends to +5V and ground
 * wiper to LCD VO pin (pin 3)

 Library originally added 18 Apr 2008
 by David A. Mellis
 library modified 5 Jul 2009
 by Limor Fried (http://www.ladyada.net)
 example added 9 Jul 2009
 by Tom Igoe
 modified 22 Nov 2010
 by Tom Igoe
 modified 7 Nov 2016
 by Arturo Guadalupi

 This example code is in the public domain.

 http://www.arduino.cc/en/Tutorial/LiquidCrystalHelloWorld

*/

// include the library code:
#include <LiquidCrystal.h>

// initialize the library by associating any needed LCD interface pin
// with the arduino pin number it is connected to
const int rs = 12, en = 11, d4 = 4, d5 = 5, d6 = 6, d7 = 7;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

void setup() {
  // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
  // Print a message to the LCD.
  lcd.print("hello, world!");
}

void loop() {
  // set the cursor to column 0, line 1
  // (note: line 1 is the second row, since counting begins with 0):
  lcd.setCursor(0, 1);
  // print the number of seconds since reset:
  lcd.print(millis() / 1000);
}


Yes, you could use an LCD with an I2C interface. You could then control it using just 4 pins. You could even add such an interface to your current LCD screen



grafik

But simplifying is a nice-to-have, you have enough pins to do what you originally stated.

I tried connecting the keypad to my nano with a shift register, but it kept saying buttons where pressed when I was not pressing any. Does anyone know if I have this wired wrong or was it a code issue?


Based on what I know with shift registers this is an untested example of the components and the way I want them hooked up.

you must write own library for such using of LCD and learn more about keypad and 74hc595.

grafik

Any chance your breadboard looks something like this?

breadboard small.PNG

No the rails are connect all the way down. Its looking like I will need to find out how to get the 4x4 keypad to work with the shift register. Let me know if you have any thoughts on that.

Should you use a 165 input register for the keypad? 595 is for output.

Got a link you can post?

1 Like

Thanks for getting the link. Are you saying the 595 will not work? After a bit of reading it looks like you can maby do it with two 595's, one for the column and one for the rows but I have been unable to get it to work yet.

@babytiger7733 that. For keypad scanning you need 4 inputs and 4 outputs.