Go Down

Topic: Serial.begin(9600); interfering with 16x2 dispaly (Read 985 times) previous topic - next topic

Sir_Morfield

So I have this problem, in my code i want to show the values on a lcd, and on the serial monitor.
But when I add the "Serial.begin(9600);" The lcd starts to display weird tokens and sometimes does nothing.

.

So it is serial monitor OR lcd.
But I want both.
I tested the display with the code that i got from the Arduino Projects book, then the dispay works fine, (even with the other pins than in the original code)
This is my example code:

Code: [Select]

#include <LiquidCrystal.h>
LiquidCrystal lcd(0, 1, 5, 4, 3, 2);

int count = 1 ;



void setup() {
  Serial.begin(9600); //If I leave this line in, it can show it on on serial monitor, but not on the lcd.
                      //If I remove the line it will only show the numbers on the lcd, not on the serial monitor.
 
  lcd.begin(16, 2);
  lcd.clear() ;
  delay(2000) ;
}
 
  void loop() {


Serial.print(count++) ;
 Serial.println() ;

  lcd.home();
  lcd.print(count);
 
  lcd.setCursor(0, 1);
  lcd.print(count);
 
 delay(2000) ;

  }

david_prentice

Yes.   0, 1 are used by the Serial.   You can't use for LCD at the same time.

chummer1010

You will need to connect the two pins that are connected to 0 and 1 elsewhere, and modify the code accordingly.
#include <signature.h>

Sir_Morfield


bodmer

Formerly Rowboteer (now a broken user profile!)

Go Up