Posts: 1
Joined: Mon Oct 15, 2012 5:34 pm

Parallax 2x16 Serial LCD

Mon Oct 15, 2012 5:49 pm

I'm trying to connect the Serial LCD with Raspberry PI. Using
minicom -D /dev/ttyAMA0 -b 9600
I can connect and type characters to the display, but then after a second or two, character disappears, sort of reset.
I tried python and node-js serial libraries, but no joy. I modified /etc/inittab to disable getty as well. I've connected GPIO 2 (5v), 6 (GND) and 8 (TX) with the LCD module.

I tried stty and echo text to /dev/ttyAMA0, but same behavior. I am not sure if the problem is with Raspberry Pi or my serial configuration. The LCD works fine with Arduino.

Would really appreciate if anyone have ANSI C code that demonstrate use of serial LCD on any Linux box? then i can work backward to ensure i'm initializing the serial connection properly for RPi.

http://www.parallax.com/Store/Microcont ... roductName

Papa G
Posts: 13
Joined: Thu Oct 18, 2012 5:21 pm
Location: Dallas, TX

Re: Parallax 2x16 Serial LCD

Thu Oct 18, 2012 11:50 pm

Did you remove all references to /dev/ttyAMA0 in /boot/cmdline.txt also?

Posts: 2
Joined: Tue Nov 20, 2012 1:13 am

Re: Parallax 2x16 Serial LCD

Tue Nov 20, 2012 1:18 am

Removing the references in cmdline.txt and commenting out the line in inittab worked for me. However I have a different issue. Same display wired to the 5v, GND, and TX pins on the pi, I can't figure out how to light the backlight. The parallax documentation says that a decimal 17 or hex 11 will enable the back light. I can get the light to turn on on the arduino by doing a serial.write "17"

I have tried echo -en '\x11' > /dev/ttyAMA0 and other iterations of the echo command. If any one out there has any ideas I would appreciate it.

Posts: 2
Joined: Fri Aug 24, 2012 7:31 pm

Re: Parallax 2x16 Serial LCD

Tue Nov 20, 2012 4:00 pm

I too am hoping to use this device with the Pi. Can any of you post the procedure you used to get it working? So far here is what I've gathered from this thread:
  • Remove all references to /dev/ttyAMA0 in /boot/cmdline.txt
    Modify /etc/inittab to disable getty
    Connect the Pi's GPIO 2 (5v), 6 (GND) and 8 (TX) pins to the LCD
    Try sending commands like:

    Code: Select all

     echo -en '\x11' > /dev/ttyAMA0
I've read through the material at the Parallax site (http://learn.parallax.com/KickStart/27977), but I'd really like to use Python on the Pi. Thanks!

Posts: 2
Joined: Tue Nov 20, 2012 1:13 am

Re: Parallax 2x16 Serial LCD

Wed Nov 21, 2012 9:48 pm

Hello davidbradway!

I did pretty much exactly what you said. I removed the references in cmdline.txt and disabled getty in inittab. Your echo command is also spot on, I did manage to get it going shortly after I posted, in my initial attempts I had the incorrect syntax. I have not used python to work my lcd I have been using shell scripting to output different info to the screen like cpu temp, ip address. That is about all I have accomplished so far. As far as python goes maybe this will help. http://code.google.com/p/raspberry-gpio-python/

Good luck!

Posts: 2
Joined: Fri Aug 24, 2012 7:31 pm

Re: Parallax 2x16 Serial LCD

Fri Nov 30, 2012 7:37 pm

I got this device to work with the Pi using Python's pyserial package. I didn't get the backlight or speaker to work, but here is my Hello World program:

Code: Select all

#!/usr/bin/env python
import serial
# configure the serial connection
ser = serial.Serial(port='/dev/ttyAMA0',baudrate=9600)
if ser.isOpen():
    ser.write(chr(12)) # 12 clear and reset cursor
    ser.write(chr(13)) # 13 Starts a new line

Posts: 1
Joined: Tue Sep 03, 2013 11:17 pm

Re: Parallax 2x16 Serial LCD

Tue Sep 03, 2013 11:34 pm

Below find a very rough Python script to scroll text on the Parallax LCD. You need to set your LCD's char width before you run it (i.e., SCREEN_WIDTH). You'll also see how to turn on the back light using Python in the script. Make sure you properly set the baudrate to 9600 using the switches on the back of the LCD device.

You'll need to download and install pyserial if you haven't already: http://pyserial.sourceforge.net/pyserial.html You'll also have to run the Python script below as root, or add your pi username ('pi' by default) to the dialout group:

Code: Select all

sudo usermod -a -G dialout username
Attach your pi's ground, 5v, and serial out (TxD) to the appropriate pins on the back of the Parallax LCD device and you're good to go. Pins vary depending on what rev you have of the RPi, so check your version's pins just to be sure at: http://wiringpi.com/pins/

Code: Select all

import serial,time

# Set screen width in characters

# Initialize serial connection
ser = serial.Serial(port='/dev/ttyAMA0', baudrate=9600)

# Set display to with cursor blink (25 for blinking cursor)

# Set backlight to true

# Clear screen; we must pause at least 5 ms after this command

def scrolltext(text):

    # Move cursor to far right of screen, in preparation for scrolling
    cursor_start = 143

    # Initialize window's head and tail
    head = tail = 0

    while tail <= len(text):

        # Actually move the cursor to the far right as set above

        # Write out text "window"

        # Move the start cursor depending on whether or not the text
        # has reached the far left of the screen, as it scrolls to the left
        cursor_start = cursor_start - 1 if not cursor_start <= 128 else 128

        # Updated window  tail
        tail += 1

        # Update window head
        head = head + 1 if tail >= SCREEN_WIDTH else 0


# Now scroll some text
scrolltext("Now let's test this thing")

Posts: 10
Joined: Wed May 30, 2012 7:18 pm

Re: Parallax 2x16 Serial LCD

Mon Sep 09, 2013 2:12 pm

Thank you Esbullington.
Just the code I was looking for.
I have figured out how to get the date and time on one line.
I just need to find out how to make it update every second for a real time clock display.

Return to “Other projects”