What do i have to buy to run an LCD Screen

Hi Guys,

i bourght an LCD 162C LED: LCD-Modul, 2x16, H:5,6mm, ge - gn, m.Bel. bei reichelt elektronik
but sadly i cant controll it with my Banana Pi Pro because the Rpi.GPIO dont work there.

So im here to ask you guys what i've to buy to Controll this LCD with Python because i dont just find 1 kind of Arduino.

And is an Arduino like an Pi or like a accessories?

Do i have to controll it to a PC/Pi or can it run alone?

masterholdy:
but sadly I cant control it with my Banana Pi Pro because the Rpi.GPIO don’t work there.

I am sure you are dead wrong there. Why do you say that?

If it has six available GPIO pins, you can run that display from it.

Alternatively, if it has an available I2C interface (and I'll bet it does) you can use an I2C "backpack" to operate the display.

The Arduino is a microcontroller module which operates alone - or in conjunction with whatever else you need it to. A very much more basic form of what the Pi is.

lel it coast close to the price of an arduino? :c

if you would be in my shoes what would you do?

sry for my bad english

//edit just saw that there ofc 3€ alternatives from cn but it would take month to receive

Hi masterholdy, and welcome to the Arduino forum.

Your questions are puzzling me, i can't figure out what you want to know (must be because of some translation).

Displays like these can be controlled by anything that works on a 5 volt level.
You might want to look into 3 to 5 volt level converters to get it to work correctly with your Pi (but it should work anyway because 3 volts also is a valid HIGH).
There's a minimum of 6 wires you need to control.

An Arduino is more like that Pi (but in a much smaller and slower form) of yours and most of it's accessories are referred to as shields.
A Pi is a PC with a processor, memory, Graphics controller, USB and network support.
An Arduino is a controller with limited memory which needs additional hardware to do USB, network and alike.

The 'basic' Uno is perfectly capable of controlling this display: click here !.

This display can't be used stand alone, it needs to be controlled.
You can decide what has to control it: An Arduino, or a PC like the Pi or whatever.

Seems to me you are a software guy.
Pi is nice and much more powerful than an Arduino.
Arduino is much more suitable to do your first steps in understanding hardware and controlling it (because you do not need to keep the OS alive for instance).
As a bonus: Arduinos can be had for much less money.
But of course it is all up to you whether you like to try or not.

MAS3:
Displays like these can be controlled by anything that works on a 5 volt level.

Or 3.3 V.

I was trying to extract the actual reason why he though the Pi would not be able to interface with it. So far, no luck. :roll_eyes:

A Pi (of whatever flavour) can control the display via its 3 V GPIO - the interface is one direction from PC to display. You just have to power the LCD at 5V.

If you use the I2C backpack, you just unsolder the two pull-up resistors from the backpack and wire 4k7 pull-ups from SDA and SCL to the +3.3 V.

i've got a "banana pi pro" its not equal to an rasbperry pi it has 2 5V Ports

ill try to explain what i want again:
i wrote a python script which can display the current wlan status of my fritzbox (Wlan Off / On)
which has more features like changing ip, turning wlan on/off,collect whos in the network and return it in an array, get the current ip, chaning the status of the internetfilter etc

im looking for a way to access the funktions e.g. turning wlan off per switch and meanwhile displaying the Status to the lcd

This is the script i wrote #!/usr/bin/pythonimport re,hashlib,requests,sys,time,threadingclass FritzBox - Pastebin.com
i would call it like this and i would change the print to the function which controlls the display print was just to test it in generell, i tested over 10 tutorials and i just cant get it to work even the guys from the lemaker board (producer of the banana pi) cant help

from FritzBoxApi import *
fb = FritzBoxApi('192.168.178.1','mypw','myssid')
fb.getsid()
time.sleep(1)
sprev=-1
while 1:
if(fb.pause == 0):
scur = fb.status()
if(sprev != scur):
print(fb.ctime() + " | "+ fb.status())
sprev = scur
else:
time.sleep(0.5)
time.sleep(1)

this is how i connected everything

masterholdy:
i've got a "banana pi pro" its not equal to an rasbperry pi it has 2 5V Ports

Sounds generally incompatible with anything.

Please post a link to the page which fully specifies its interfaces.

http://www.lemaker.org/article-43-1.html
http://wiki.lemaker.org/LeMaker_Banana_Pro/Pi

masterholdy:
i've got a "banana pi pro" its not equal to an rasbperry pi it has 2 5V Ports

You had me puzzled there - I thought you were saying "2**.**5 V" ports.

Looking at the GPIO pinouts, I see 5 V and 3.3 V supply lines, and I would be extremely surprised if the GPIO lines were not - exactly as with the Raspberry Pi - 3.3V logic levels. In any case, they should be directly compatible with the LCD display, or with an I2C interface as I described.

how would i controll an l2c interface if i bourght one? i followed like 10 tutorials and i couldnt get it to work normally via gpio

masterholdy:
this is how i connected everything

OK, just looked at that. Obviously you are using the 5V supply and ground from the GPIO.

Should interface just fine, but the pin numbers are somewhat odd - usually the data pins will be in direct sequence making the code simpler.

Either you have a library to control the LCD, in which case all the (GPIO pin) setup details will be with the library, or you write your own code which is just a little challenging.

It's all in the code; get the code right and it will work. Of course, you need to set up the contrast to start with so that with no code at all running on the display since switch-on, you see the line of "boxes" on the first row.

And you do not need a resistor in series with the LED if resistor R8 (or R9) on the LCD board is "101", meaning 100 ohms.


masterholdy:
how would I control an l2c interface if I bought one? I followed like 10 tutorials and I couldn't get it to work normally via gpio

Steady on! First things first! :grinning:

Following 10 tutorials sounds very dangerous to me! :astonished: The tricky bit with tutorials is to figure out which one is written by someone who actually knows what (s)he is doing, and work with that one, figuring out what little details need to be adjusted for your particular situation.

It would be foolish indeed to go for I2C unless and until you can get the direct connection working. This clearly has nothing to do with Arduino so you would in general, be better to refer to the Banana Pi forums, but if you continue to look for assistance here, you would need to show your test code (which of course is just to print "Hello World" and has nothing whatever to do with Fritzbox or WLAN or such) and cite your libraries (and in particular, the documentation for those libraries).

i already love this forum so fast answers
this is a list of a few tutorials i tried i always connected it the same way just changed the pins in the script

http://www.tutorials-raspberrypi.de/gpio/text-auf-16x2-zeichen-lcd-display-anzeigen-hd44780/ (its based on this script http://www.tutorials-raspberrypi.de/wp-content/uploads/scripts/hd44780_test.py)
http://www.rdklein.eu/rdpiforum/viewtopic.php?f=36&t=2628

so i change in every script RS = 25, E =24, DATA4 23, DATA5 = 1,DATA6 =27,DATA7=22

So you need to explain:

  • Did you set up the display to see the first row of blocks with no code running?
  • Did you (only) then get the code to initialise the display so that the blocks are even in both rows?
  • Did you then get anything at all to display?
  • What exactly was your test code at that point?

the display looks at all stages the same in the first row i see blocks nothing more nothing less :frowning:

  1. it displays the blocks even w/o code
  2. ^
  3. sadly no
  4. this for instance with changed values for the gpio
    http://www.tutorials-raspberrypi.de/wp-content/uploads/scripts/hd44780_test.py

masterholdy:
4) this for instance with changed values for the gpio
http://www.tutorials-raspberrypi.de/wp-content/uploads/scripts/hd44780_test.py

Well, the numbers in that do not match your diagram, so being just as finicky as I am (and most of us here), I would want the version you are using (post it as "code" according to the instructions) just to prove you have made the correct substitution and I am very suspicious about the label "GPIO.1" on your diagram. Why do you need to use such a different pin? As a matter of fact, is there perhaps something else connected to the GPIO?

In fact, my concern here would be that I would like to see (that you have) test code proving that it can send correct outputs to a set of LEDs with 1k resistors connected to those ports.

atm i just connected the lcd to the gpio i already connected the background 5v pin from the lcd to an gpio port to test whether i can controll it atleast that worked and loked like "gpio write 29 1"
i can controll led's aswell and already used an radio transmitter 433mhz and it worked

#!/usr/bin/python

#
# based on code from lrvick and LiquidCrystal
# lrvic - https://github.com/lrvick/raspi-hd44780/blob/master/hd44780.py
# LiquidCrystal - https://github.com/arduino/Arduino/blob/master/libraries/LiquidCrystal/LiquidCrystal.cpp
#

from time import sleep


class Adafruit_CharLCD(object):

    # commands
    LCD_CLEARDISPLAY        = 0x01
    LCD_RETURNHOME          = 0x02
    LCD_ENTRYMODESET        = 0x04
    LCD_DISPLAYCONTROL      = 0x08
    LCD_CURSORSHIFT         = 0x10
    LCD_FUNCTIONSET         = 0x20
    LCD_SETCGRAMADDR        = 0x40
    LCD_SETDDRAMADDR        = 0x80

    # flags for display entry mode
    LCD_ENTRYRIGHT          = 0x00
    LCD_ENTRYLEFT           = 0x02
    LCD_ENTRYSHIFTINCREMENT = 0x01
    LCD_ENTRYSHIFTDECREMENT = 0x00

    # flags for display on/off control
    LCD_DISPLAYON           = 0x04
    LCD_DISPLAYOFF          = 0x00
    LCD_CURSORON            = 0x02
    LCD_CURSOROFF           = 0x00
    LCD_BLINKON             = 0x01
    LCD_BLINKOFF            = 0x00

    # flags for display/cursor shift
    LCD_DISPLAYMOVE         = 0x08
    LCD_CURSORMOVE          = 0x00

    # flags for display/cursor shift
    LCD_DISPLAYMOVE         = 0x08
    LCD_CURSORMOVE          = 0x00
    LCD_MOVERIGHT           = 0x04
    LCD_MOVELEFT            = 0x00

    # flags for function set
    LCD_8BITMODE            = 0x10
    LCD_4BITMODE            = 0x00
    LCD_2LINE               = 0x08
    LCD_1LINE               = 0x00
    LCD_5x10DOTS            = 0x04
    LCD_5x8DOTS             = 0x00

    def __init__(self, pin_rs=25, pin_e=24, pins_db=[23, 1, 27, 22], GPIO=None):
        # Emulate the old behavior of using RPi.GPIO if we haven't been given
        # an explicit GPIO interface to use
        if not GPIO:
            import RPi.GPIO as GPIO
            GPIO.setwarnings(False)
        self.GPIO = GPIO
        self.pin_rs = pin_rs
        self.pin_e = pin_e
        self.pins_db = pins_db

        self.GPIO.setmode(GPIO.BCM)
        self.GPIO.setup(self.pin_e, GPIO.OUT)
        self.GPIO.setup(self.pin_rs, GPIO.OUT)

        for pin in self.pins_db:
            self.GPIO.setup(pin, GPIO.OUT)

        self.write4bits(0x33)  # initialization
        self.write4bits(0x32)  # initialization
        self.write4bits(0x28)  # 2 line 5x7 matrix
        self.write4bits(0x0C)  # turn cursor off 0x0E to enable cursor
        self.write4bits(0x06)  # shift cursor right

        self.displaycontrol = self.LCD_DISPLAYON | self.LCD_CURSOROFF | self.LCD_BLINKOFF

        self.displayfunction = self.LCD_4BITMODE | self.LCD_1LINE | self.LCD_5x8DOTS
        self.displayfunction |= self.LCD_2LINE

        # Initialize to default text direction (for romance languages)
        self.displaymode = self.LCD_ENTRYLEFT | self.LCD_ENTRYSHIFTDECREMENT
        self.write4bits(self.LCD_ENTRYMODESET | self.displaymode)  # set the entry mode

        self.clear()

    def begin(self, cols, lines):
        if (lines > 1):
            self.numlines = lines
            self.displayfunction |= self.LCD_2LINE

    def home(self):
        self.write4bits(self.LCD_RETURNHOME)  # set cursor position to zero
        self.delayMicroseconds(3000)  # this command takes a long time!

    def clear(self):
        self.write4bits(self.LCD_CLEARDISPLAY)  # command to clear display
        self.delayMicroseconds(3000)  # 3000 microsecond sleep, clearing the display takes a long time

    def setCursor(self, col, row):
        self.row_offsets = [0x00, 0x40, 0x14, 0x54]
        if row > self.numlines:
            row = self.numlines - 1  # we count rows starting w/0
        self.write4bits(self.LCD_SETDDRAMADDR | (col + self.row_offsets[row]))

    def noDisplay(self):
        """ Turn the display off (quickly) """
        self.displaycontrol &= ~self.LCD_DISPLAYON
        self.write4bits(self.LCD_DISPLAYCONTROL | self.displaycontrol)

    def display(self):
        """ Turn the display on (quickly) """
        self.displaycontrol |= self.LCD_DISPLAYON
        self.write4bits(self.LCD_DISPLAYCONTROL | self.displaycontrol)

    def noCursor(self):
        """ Turns the underline cursor off """
        self.displaycontrol &= ~self.LCD_CURSORON
        self.write4bits(self.LCD_DISPLAYCONTROL | self.displaycontrol)

    def cursor(self):
        """ Turns the underline cursor on """
        self.displaycontrol |= self.LCD_CURSORON
        self.write4bits(self.LCD_DISPLAYCONTROL | self.displaycontrol)

    def noBlink(self):
        """ Turn the blinking cursor off """
        self.displaycontrol &= ~self.LCD_BLINKON
        self.write4bits(self.LCD_DISPLAYCONTROL | self.displaycontrol)

    def blink(self):
        """ Turn the blinking cursor on """
        self.displaycontrol |= self.LCD_BLINKON
        self.write4bits(self.LCD_DISPLAYCONTROL | self.displaycontrol)

    def DisplayLeft(self):
        """ These commands scroll the display without changing the RAM """
        self.write4bits(self.LCD_CURSORSHIFT | self.LCD_DISPLAYMOVE | self.LCD_MOVELEFT)

    def scrollDisplayRight(self):
        """ These commands scroll the display without changing the RAM """
        self.write4bits(self.LCD_CURSORSHIFT | self.LCD_DISPLAYMOVE | self.LCD_MOVERIGHT)

    def leftToRight(self):
        """ This is for text that flows Left to Right """
        self.displaymode |= self.LCD_ENTRYLEFT
        self.write4bits(self.LCD_ENTRYMODESET | self.displaymode)

    def rightToLeft(self):
        """ This is for text that flows Right to Left """
        self.displaymode &= ~self.LCD_ENTRYLEFT
        self.write4bits(self.LCD_ENTRYMODESET | self.displaymode)

    def autoscroll(self):
        """ This will 'right justify' text from the cursor """
        self.displaymode |= self.LCD_ENTRYSHIFTINCREMENT
        self.write4bits(self.LCD_ENTRYMODESET | self.displaymode)

    def noAutoscroll(self):
        """ This will 'left justify' text from the cursor """
        self.displaymode &= ~self.LCD_ENTRYSHIFTINCREMENT
        self.write4bits(self.LCD_ENTRYMODESET | self.displaymode)

    def write4bits(self, bits, char_mode=False):
        """ Send command to LCD """
        self.delayMicroseconds(1000)  # 1000 microsecond sleep
        bits = bin(bits)[2:].zfill(8)
        self.GPIO.output(self.pin_rs, char_mode)
        for pin in self.pins_db:
            self.GPIO.output(pin, False)
        for i in range(4):
            if bits[i] == "1":
                self.GPIO.output(self.pins_db[::-1][i], True)
        self.pulseEnable()
        for pin in self.pins_db:
            self.GPIO.output(pin, False)
        for i in range(4, 8):
            if bits[i] == "1":
                self.GPIO.output(self.pins_db[::-1][i-4], True)
        self.pulseEnable()

    def delayMicroseconds(self, microseconds):
        seconds = microseconds / float(1000000)  # divide microseconds by 1 million for seconds
        sleep(seconds)

    def pulseEnable(self):
        self.GPIO.output(self.pin_e, False)
        self.delayMicroseconds(1)       # 1 microsecond pause - enable pulse must be > 450ns
        self.GPIO.output(self.pin_e, True)
        self.delayMicroseconds(1)       # 1 microsecond pause - enable pulse must be > 450ns
        self.GPIO.output(self.pin_e, False)
        self.delayMicroseconds(1)       # commands need > 37us to settle

    def message(self, text):
        """ Send string to LCD. Newline wraps to second line"""
        for char in text:
            if char == '\n':
                self.write4bits(0xC0)  # next line
            else:
                self.write4bits(ord(char), True)


if __name__ == '__main__':
    lcd = Adafruit_CharLCD()
    lcd.clear()
    lcd.message(" Banana Pi\n     by ALLNET")
    time.sleep(10)

So as I interpret that, you used the backlight to test whether the GPIO pins were responding as predicted. Fair enough.

Does the code you just posted work, or not?

As per my previous questions, is there anything else connected to the GPIO, and why are you using GPIO.1? Is there perhaps something special about GPIO.1 (as there happens to be in the Arduino!)?

this are all pins

theres nothing else connected to the pins

the code dont work but and i dont get exceptions nor errors

i solved the problem i used the gpio library and i have to use the BCM numbers there and not the gpio layout numbers

Paul i rly appreciated the help! :slight_smile: you are very kind