Why my display 1 and 2 are switching with others, like blinking?

#include <LiquidCrystal.h>
int sensorValue1 = 1;
int sensorValue2 = 2;

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd1(12, 11, 5, 4, 3, 2);
LiquidCrystal lcd2(12, 10, 5, 4, 3, 2);

void setup()
{
pinMode(A1, INPUT);
// set up the LCD1's number of columns and rows:
lcd1.begin(16, 2);
Serial.begin(9600);

pinMode(A2, INPUT);
// set up the LCD2's number of columns and rows:
lcd2.begin(16, 2);
Serial.begin(9600);
}

void loop()
{
// read the input on analog pin 1:
sensorValue1 = analogRead(A1);
// set the cursor to column 0, line 0:
lcd1.setCursor(4, 2);
// print out the value at LCD1 Display:
lcd1.print(sensorValue1);
lcd1.setCursor(10, 2);
lcd1.print("GHz");
// print out the value at Serial Monitor:
Serial.println(sensorValue1);
delay(1000);
lcd1.clear();

// read the input on analog pin 2:
sensorValue2 = analogRead(A2);
// set the cursor to column 0, line 0:
lcd2.setCursor(4, 2);
// print out the value at LCD2 Display:
lcd2.print(sensorValue2);
lcd2.setCursor(10, 2);
lcd2.print("GHz");
// print out the value at Serial Monitor:
Serial.println(sensorValue2);
delay(1000);
lcd2.clear();
}

Help us help you.

1 Like

go to the following steps

clear1
clear2
measure1
measure2
display1
display2
serial.....

no need to "delay(1000)"

1 Like

looks like you're alternately displaying 2 analog values at the same positions on the LCD. isn't this what you want?

or do you want to display each on separate rows?

1 Like

Yes, I want to display it to separate rows. I am using a separate potentiometer to control the number of values displaying on the lcd1 and lcd2.

should you set the cursor to 4,1 and 10,1?

1 Like

I think this will develop into the XY problem

1 Like

It keeps on blinking sir gcjr
noname

noname

#include <LiquidCrystal.h>
int sensorValue1 = 1;
int sensorValue2 = 2;

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd1(12, 11, 5, 4, 3, 2);
LiquidCrystal lcd2(12, 10, 5, 4, 3, 2);

void setup() {
pinMode(A1, INPUT);
// set up the LCD1's number of columns and rows:
lcd1.begin(16, 2);
Serial.begin(9600);

pinMode(A2, INPUT);
// set up the LCD2's number of columns and rows:
lcd2.begin(16, 2);
Serial.begin(9600);
}

void loop() {
// read the input on analog pin 1:
sensorValue1 = analogRead(A1);
// set the cursor to column 0, line 0:
lcd1.setCursor(4, 2);
// print out the value at LCD1 Display:
lcd1.print(sensorValue1);
lcd1.setCursor(10, 2);
lcd1.print("GHz");
// print out the value at Serial Monitor:
Serial.println(sensorValue1);
delay(1000);
lcd1.clear();

// read the input on analog pin 2:
sensorValue2 = analogRead(A2);
// set the cursor to column 0, line 0:
lcd2.setCursor(4, 2);
// print out the value at LCD2 Display:
lcd2.print(sensorValue2);
lcd2.setCursor(10, 2);
lcd2.print("GHz");
// print out the value at Serial Monitor:
Serial.println(sensorValue2);
delay(1000);
lcd2.clear();
}

Merci

What am I supposed to do with it now?

sorry. i thought there was just one LCD.

why do you have 2 delays?
re-read @demkat1 post #3

Can you use code tags to make your code look more like this:

#include <LiquidCrystal.h>
int sensorValue1 = 1;
int sensorValue2 = 2;

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd1(12, 11, 5, 4, 3, 2);
LiquidCrystal lcd2(12, 10, 5, 4, 3, 2);

void setup() {

That way the code is easier to read and work with.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.