I am using the Arduino Uno with SerLCD (3pins), i connect the LCD Vdd to the Uno 5V, GND to GND, and LCD RX to the Uno TX which is at pin digital (PWM (1)). I am using the SoftwareSerial Example, i change the baud rate to 9600. Everytime i upload the code it gave me a bunch of characters as soon as i unplug it and plug i it back i see the right output. Can anyone help please!!!
/*
Software serial multple serial test
Receives from the hardware serial, sends to software serial.
Receives from software serial, sends to hardware serial.
The circuit:
* RX is digital pin 2 (connect to TX of other device)
* TX is digital pin 3 (connect to RX of other device)
created back in the mists of time
modified 9 Apr 2012
by Tom Igoe
based on Mikal Hart's example
This example code is in the public domain.
*/
#include <SoftwareSerial.h>
SoftwareSerial mySerial(2, 3); // RX, TX
void setup()
{
// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
Serial.println("Goodnight moon!");
// set the data rate for the SoftwareSerial port
mySerial.begin(4800);
mySerial.println("Hello, world?");
}
void loop() // run over and over
{
if (mySerial.available())
Serial.write(mySerial.read());
if (Serial.available())
mySerial.write(Serial.read());
}
This is a well known problem. Digital pins 0 and 1 are shared with the communications channel that goes between the ATmega MCU and the USB/serial converter. Whenever data goes over the USB connection, it’ll show on these pins. The pins that are brought out to the header (D0, D1) are buffered by 1k (IIRC) resistors. If you’re using a software emulation of a serial port, use a different pin and avoid the sharing.
Mee_n_Mac is correct that pins 0 and 1 are shared with the USB downloader. But in your case you seem to be using pins 2 and 3 using the softserial library. Your mySerial object should print to the LCD and the Serial object to the Arduin IDE.
Are you saying that during uploads you get data to the LCD? Could you move your serial pins to 4 and 5 as a test to see if the problem continues?
fll-freak:
Mee_n_Mac is correct that pins 0 and 1 are shared with the USB downloader. But in your case you seem to be using pins 2 and 3 using the softserial library. Your mySerial object should print to the LCD and the Serial object to the Arduin IDE. Are you saying that during uploads you get data to the LCD? Could you move your serial pins to 4 and 5 as a test to see if the problem continues?
Could the OP have the wiring to digital pin 1 and have the software using digital pin 3 (for the TX to the LCD) ? Perhaps all he needs to do is move the wire from 1 to 3 ?? It seems that the SW has the LCD just echo what’s typed on the serial monitor port so it makes sense that he get’s the “right output” (once booted) if connected to either pin.
The problem still continue, i moved pin 1 to 3 it didn’t work at all. When i change pin 2,3 to 4,5 and to 0,1 it still work the same way; whenever i upload the code its a bunch of characters as so as i unplug the USB and plug it back i get to right output.
According to the code you posted, the connection should be from pin3 of the Uno to the RX pin of the serial LCD. Also did you permanently change this line …
mySerial.begin(4800);
… to be 9600 baud ? If not you should.
Yep i just double check pin1 from the Uno with is TX it goes to RX pin of the LCD
and i change that line you said, it still does the same thing i could only see the output after unplug and plug back.
try this , and change #define txPin 2 to you pin , if you are using pin 8 then make it #define txPin 8
#include <SoftwareSerial.h>
#define txPin 2
SoftwareSerial LCD = SoftwareSerial(0, txPin);
// since the LCD does not send data back to the Arduino, we should only define the txPin
const int LCDdelay=10; // conservative, 2 actually works
// wbp: goto with row & column
void lcdPosition(int row, int col) {
LCD.write(0xFE); //command flag
LCD.write((col + row*64 + 128)); //position
delay(LCDdelay);
}
void clearLCD(){
LCD.write(0xFE); //command flag
LCD.write(0x01); //clear command.
delay(LCDdelay);
}
void backlightOn() { //turns on the backlight
LCD.write(0x7C); //command flag for backlight stuff
LCD.write(157); //light level.
delay(LCDdelay);
}
void backlightOff(){ //turns off the backlight
LCD.write(0x7C); //command flag for backlight stuff
LCD.write(128); //light level for off.
delay(LCDdelay);
}
void serCommand(){ //a general function to call the command flag for issuing all other commands
LCD.write(0xFE);
}
void setup()
{
pinMode(txPin, OUTPUT);
LCD.begin(9600);
clearLCD();
lcdPosition(0,0);
LCD.print("Hello world!");
}
void loop()
{
}
worked a few hours ago for me…