LCD 16x2 - Raspberry Pi Forums


hi everyone, doing new project involve in lcd 16x2 green screen. could'nt display , way allow me type message , have instantly displayed on display. link step insert lcd raspberry pi follow. dun kw error. pop out error.

link:
http://4.bp.blogspot.com/-c_isp6kwxja/u ... d44780.png

coding:

code: select all

import rpi.gpio gpio   time import sleep   class lcd:          def __init__(self, pin_rs=7, pin_e=8, pins_db=[25, 24, 23, 18]):              self.pin_rs=pin_rs           self.pin_e=pin_e           self.pins_db=pins_db              gpio.setmode(gpio.bcm)           gpio.setup(self.pin_e, gpio.out)           gpio.setup(self.pin_rs, gpio.out)           pin in self.pins_db:               gpio.setup(pin, gpio.out)              self.clear()          def clear(self):           """ blank / reset lcd """              self.cmd(0x33) # $33 8-bit mode           self.cmd(0x32) # $32 8-bit mode           self.cmd(0x28) # $28 8-bit mode           self.cmd(0x0c) # $0c 8-bit mode           self.cmd(0x06) # $06 8-bit mode           self.cmd(0x01) # $01 8-bit mode          def cmd(self, bits, char_mode=false):           """ send command lcd """              sleep(0.001)           bits=bin(bits)[2:].zfill(8)              gpio.output(self.pin_rs, char_mode)              pin in self.pins_db:               gpio.output(pin, false)              in range(4):               if bits[i] == "1":                   gpio.output(self.pins_db[::-1][i], true)              gpio.output(self.pin_e, true)           gpio.output(self.pin_e, false)              pin in self.pins_db:               gpio.output(pin, false)              in range(4,8):               if bits[i] == "1":                   gpio.output(self.pins_db[::-1][i-4], true)                 gpio.output(self.pin_e, true)           gpio.output(self.pin_e, false)          def message(self, text):           """ send string lcd. newline wraps second line"""              char in text:               if char == '\n':                   self.cmd(0xc0) # next line               else:                   self.cmd(ord(char),true)      if __name__ == '__main__':          lcd = lcd()       lcd.message("raspberry pi\n  take byte!")   
error pop out during running:
file "lcd.py",line 67 in <module>
lcd = lcd()

file "lcd.py",line 21 in clear
self.cmd(0x33)

file "lcd.py",line 37 in cmd
gpio.output(pin, false)
please me first time using lcd

that code works me when run sudo python xxx.py.


raspberrypi



Comments

Popular posts from this blog

VIDIOC_S_FMT error 16, Device or resource busy - Raspberry Pi Forums

using a laptop skeleton to build a pi laptop - Raspberry Pi Forums

Forum for Joomla? - Joomla! Forum - community, help and support