I2C LCD werkt na reset.

Dag

Als ik mijn rduino opstart krijg ik geen tekst op mijn lcd. Maar als ik deze dan reset met de arduino reset springt deze wel weer op. Hoe voeg ik een automatische reset toe in mijn programma dat deze nog eens gereset wordt bij het opstarten?

Dit is de code die ik gebruik. Maar ik weet niet waar ik de codes moeten plaatsen om deze softwarematig te resetten. Mss verhelpt resetten van het programma bij het opstarten van de arduino mijn. Probleem.

/*
Arduino keypad door entry with serial LCD output by Andrew Grayson - 2013.

Thanks for this go to Google, Arduino.cc, Instructables and the wonderfully talented people who create things and help clueless people like me understand how they did it.

This project uses a standard 12 button keypad to operate a servo that can pull a door lock.
A 20 x 4 serial LCD is used in this example so that it will operate on an UNO but if you have a mega then you can use a parallel LCD as it has more pins.

The buzz function was written by Rob Faludi - http://www.faludi.com/2007/04/23/buzzer-arduino-example-code/

This code is in the public domain.

Wiring for Serial I2C LCD:
SCL > Arduino A5
SCA > Arduino A4
GND > GND
VCC > +5v

Wiring for Servo:
Black/Brown > GND
Red > +5v
Orange/White (signal) > Arduino Pin 3

Wiring for Keypad:
This is a little tricky and depends on your model of keypad. The one used in this example is made by Sparkfun.

The pins on the keypad correspond to the three columns and four rows.
The columns from left to right are pins 3, 1, 5.
The rows from top to bottom are pins 2, 7, 6, 4.
So pressing button 5 will create a circuit between pins 1 and 7 on the keypad.

Pin 1 > Arduino 11
Pin 2 > Arduino 9 and also to a 10k Ohm resistor then to Arduino +5v
Pin 3 > Arduino 12
Pin 4 > Arduino 6 and also to a 10k Ohm resistor then to Arduino +5v
Pin 5 > Arduino 10
Pin 6 > Arduino 7 and also to a 10k Ohm resistor then to Arduino +5v
Pin 7 > Arduino 8 and also to a 10k Ohm resistor then to Arduino +5v

*/

#include <Keypad.h> //Library for the matrix keypad available from http://playground.arduino.cc/code/Keypad
#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h> //You must use F. Malpartida’s new LCD library for Serial LCD https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/Home

#define I2C_ADDR 0x27 // Define I2C Address for the LCD. This varies by device, see the data sheet for yours
// Set up serial to parallel configuration for LCD
#define BACKLIGHT_PIN 3
#define En_pin 2
#define Rw_pin 1
#define Rs_pin 0
#define D4_pin 4
#define D5_pin 5
#define D6_pin 6
#define D7_pin 7

// define an LCD instance
LiquidCrystal_I2C lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);
// define keypad mapping
const byte ROWS = 4; // Four rows
const byte COLS = 3; // Three columns
// Define the Keymap. Note the position of # and * alter between models
char keys[ROWS][COLS] = {
{‘1’,‘2’,‘3’},
{‘4’,‘5’,‘6’},
{‘7’,‘8’,‘9’},
{’*’,‘0’,’#’}
};

// Connect keypad ROW0, ROW1, ROW2 and ROW3 (top to bottom) to these Arduino pins.
byte rowPins[ROWS] = {
9, 8, 7, 6 };
// Connect keypad COL0, COL1 and COL2 (left to right) to these Arduino pins.
byte colPins[COLS] = {
12, 11, 10 };

// Create the Keypad instance
Keypad kpd = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );

void setup(){
pinMode(4, OUTPUT); // pin for relais
pinMode(3, OUTPUT); // pin for green LED
pinMode(2, OUTPUT); // pin for red LED

lcd.begin (16,2); // initialise LCD

// Switch on the backlight
lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE);
lcd.setBacklight(HIGH);
// clear the LCD
lcd.clear();
// move the cursor top left
lcd.home();
// print a message on the LCD to enter the code
lcd.print(" ENTER CODE");
lcd.setCursor(0, 1);
lcd.print("");
lcd.setCursor(0, 3);
}

void loop(){

String mastercode = “19082013”; // the password
String enteredcode = “”; // the code you enter
String reason = " INCORRECT CODE "; // the default reason why entry failed
// read a 6 digit code (you can have any length)
for (int i = 0; i < 8; i++){
char key = kpd.waitForKey();

if(key != NO_KEY){ // if you aren’t reading no keypress

lcd.print("*"); // print a # to the LCD so people don’t see the number but you know you pressed a button
enteredcode += key; // append the keypress to the end of the entered code string
}
}

if (enteredcode == mastercode) // if the code is correct
{
lcd.setCursor (0, 3);
lcd.print(" “);
lcd.setCursor (0, 1);
lcd.print(” CODE CORRECT "); // print a success message
digitalWrite(3, HIGH); // turn on the green LED
digitalWrite(4, HIGH); // turn on the relais
delay (15000); // wait 15 seconds while the door is opened
digitalWrite(3, LOW); // turn off the LED
digitalWrite(4, LOW); // turn off the relais

//reset the LCD for the next user
lcd.clear();
lcd.home();
lcd.print(" ENTER CODE");
lcd.setCursor(0, 1);
lcd.print(" “);
lcd.setCursor(0, 1);
}
else { // if the code is wrong or cancelled
// tell the user what happened
lcd.setCursor (0, 3);
lcd.print(” “);
lcd.setCursor (0, 1);
lcd.print(reason); // display the reason for failure. Incorrect code by default unless cancel is pressed
digitalWrite(2, HIGH); // turn on the red LED
delay (3000); // wait 3 seconds before allowing a retry
digitalWrite(2, LOW); // turn off LED
// reset the LCD for the next try
lcd.clear();
lcd.home();
lcd.print(” ENTER CODE");
lcd.setCursor(0, 1);
lcd.print(" ");
lcd.setCursor(0, 3);

}

}

Opgelost met pull up weerstand van 4,7k.

heel goed:
Zelf gezocht ...
zelf gevonden ...
en teruggekoppeld naar het forum.

Zo hoort het. Waarvoor dank.

Met vriendelijke groet
Jantje

hallo deswertn

ik heb hetzelfde probleem, ik ben er zelfs achter gekomen dat de LCD een aantal centimeters naast de scherm denkt te printen. (code met 6 cijfers, zie ik de laatste nummer, van die 6 cijfers. bijv. code = 123456. dan zie ik alleen de 6 aan de linkerkant)

hoe heb jij dat aangepakt met de pullup weerstand van 4,7 K ? progammeer ik dat ?

Nope..... Je moet een 4K7 pullup weerstand plaatsen op de SDA en SCL pin naar de 5V toe.