On 26/09/2019 11:08, DL Neil wrote:
On 26/09/19 9:14 PM, RobH wrote:
I have some sample/demo python code for scrolling and outputting text onto a 16x2 lcd display.

I would like to put my own message or text outputting to the lcd on 2 lines. I have tried using lcd.message('my message',1) and lcd.message('my message', 2), but the output says:

TypeError: message() takes exactly 2 arguments (3 given)

I have also seen this on the, stackexchange site:
lcd_string("your text " + str(yourVar), 1)

But what is str(yourVar), as I assume it means a variable.
If I could have a working example please, that would be great.


I'm wondering if "lcd_string" should be "lcd.string" (per "lcd.message")  - would it be better to post the actual (not) working code?

Suggest you fire-up the Python REPR:

     python3        # on a Linux terminal

then:

     import ***whatever the LCD package is called ***
     help( ***whatever...called *** )

The output from this will tell you the names of all the entities within the package. Within that you will be able to check for the pertinent class (from which lcd was derived) and see what it says about arguments for the message() and/or string() methods - particularly the number of arguments and their data-type(s).


Thanks, but was is Python REPR.
This my adaptation of non working code. Bodged from the char_lcd.py code:

GNU nano 2.7.4 File: char_lcd.py

#!/usr/bin/python
# Example using a character LCD connected to a Raspberry Pi or BeagleBone Black.
import time

import Adafruit_CharLCD as LCD


# Raspberry Pi pin configuration:
lcd_rs = 27 # Note this might need to be changed to 21 for older revision Pi's.
lcd_en        = 22
lcd_d4        = 25
lcd_d5        = 24
lcd_d6        = 23
lcd_d7        = 18
lcd_backlight = 4

# BeagleBone Black configuration:
# lcd_rs        = 'P8_8'
# lcd_en        = 'P8_10'
# lcd_d4        = 'P8_18'
# lcd_d5        = 'P8_16'
# lcd_d6        = 'P8_14'
# lcd_d7        = 'P8_12'
# lcd_backlight = 'P8_7'

# Define LCD column and row size for 16x2 LCD.
lcd_columns = 16
lcd_rows    = 2

# Alternatively specify a 20x4 LCD.
# lcd_columns = 20
# lcd_rows    = 4

# Initialize the LCD using the pins above.
lcd = LCD.Adafruit_CharLCD(lcd_rs, lcd_en, lcd_d4, lcd_d5, lcd_d6, lcd_d7,
                           lcd_columns, lcd_rows, lcd_backlight)

# Print a two line message
# lcd.message('Hello\nworld!')
lcd.message( "Hello" 1)


# Wait 5 seconds
time.sleep(5.0)

# Demo showing the cursor.
#lcd.clear()
# Wait 5 seconds
time.sleep(5.0)

# Demo showing the cursor.
#lcd.clear()
#lcd.show_cursor(True)
#lcd.message('Show cursor')
lcd.message("Your dental",1)
lcd.message("appointment is",2)

time.sleep(5.0)

# Demo showing the blinking cursor.
lcd.clear()

--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to