I2c Problem Random Characters on LCD not values
i getting random characters not values on lcd display. ideas? please see below , attach photos of lcd , setup flowmeter
#include <wire.h>
#include <lcd.h>
#include <liquidcrystal_i2c.h>
#define i2c_addr 0x27 // <<----- add address here. find i2c scanner
#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
liquidcrystal_i2c lcd(i2c_addr, en_pin, rw_pin, rs_pin, d4_pin, d5_pin, d6_pin, d7_pin);
volatile int flow_frequency; // measures flow sensor pulses
unsigned int gallons_min; // calculated gallons/min
unsigned char flowsensor = 2; // sensor input
unsigned long currenttime;
unsigned long clooptime;
void flow () // interrupt function
{
flow_frequency++;
}
void setup()
{
lcd.begin (20, 4); //change if need to
lcd.setbacklightpin(backlight_pin, positive);
lcd.setbacklight(high);
lcd.home();
pinmode(flowsensor, input);
digitalwrite(flowsensor, high); // optional internal pull-up
serial.begin(9600);
attachinterrupt(0, flow, rising); // setup interrupt
sei(); // enable interrupts
currenttime = millis();
clooptime = currenttime;
}
void loop ()
{
currenttime = millis();
// every second, calculate , print gallons/hour
if (currenttime >= (clooptime + 1000))
{
clooptime = currenttime; // updates clooptime
// pulse frequency (hz) = 60q, q flow rate in gallons/min
gallons_min = (flow_frequency * 100 / 60); // (pulse frequency x 1 min) / 60q = flowrate in gallons/min
flow_frequency = 0; // reset counter
serial.print(gallons_min); // print gallons/min
serial.println("gallons/min"); delay(100);
lcd.print("text");
lcd.print("text");
lcd.clear();
lcd.setcursor(0, 0);
}
}
#include <wire.h>
#include <lcd.h>
#include <liquidcrystal_i2c.h>
#define i2c_addr 0x27 // <<----- add address here. find i2c scanner
#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
liquidcrystal_i2c lcd(i2c_addr, en_pin, rw_pin, rs_pin, d4_pin, d5_pin, d6_pin, d7_pin);
volatile int flow_frequency; // measures flow sensor pulses
unsigned int gallons_min; // calculated gallons/min
unsigned char flowsensor = 2; // sensor input
unsigned long currenttime;
unsigned long clooptime;
void flow () // interrupt function
{
flow_frequency++;
}
void setup()
{
lcd.begin (20, 4); //change if need to
lcd.setbacklightpin(backlight_pin, positive);
lcd.setbacklight(high);
lcd.home();
pinmode(flowsensor, input);
digitalwrite(flowsensor, high); // optional internal pull-up
serial.begin(9600);
attachinterrupt(0, flow, rising); // setup interrupt
sei(); // enable interrupts
currenttime = millis();
clooptime = currenttime;
}
void loop ()
{
currenttime = millis();
// every second, calculate , print gallons/hour
if (currenttime >= (clooptime + 1000))
{
clooptime = currenttime; // updates clooptime
// pulse frequency (hz) = 60q, q flow rate in gallons/min
gallons_min = (flow_frequency * 100 / 60); // (pulse frequency x 1 min) / 60q = flowrate in gallons/min
flow_frequency = 0; // reset counter
serial.print(gallons_min); // print gallons/min
serial.println("gallons/min"); delay(100);
lcd.print("text");
lcd.print("text");
lcd.clear();
lcd.setcursor(0, 0);
}
}
you got i2c backpacked lcd display.
so need i2c library, ok.
but why include "normal" lcd library ?
delete
and see happens then.
if doesn't work have search more issues.
so need i2c library, ok.
but why include "normal" lcd library ?
delete
code: [select]
#include <lcd.h>
and see happens then.
if doesn't work have search more issues.
Arduino Forum > Using Arduino > Displays > I2c Problem Random Characters on LCD not values
arduino
Comments
Post a Comment