Created
April 14, 2015 02:43
-
-
Save itrobotics/f227d48893b4e1a858e8 to your computer and use it in GitHub Desktop.
The initialization of the LCD1602 Module implemented by Python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import RPi.GPIO as GPIO | |
from time import sleep | |
def init(): | |
GPIO.setmode(GPIO.BCM) | |
RS = 20 | |
RW = 21 | |
EN = 26 | |
D4 = 19 | |
D5 = 13 | |
D6 = 6 | |
D7 = 5 | |
GPIO.setup(EN, GPIO.OUT) | |
GPIO.setup(RS, GPIO.OUT) | |
GPIO.setup(RW, GPIO.OUT) | |
GPIO.setup(D4, GPIO.OUT) | |
GPIO.setup(D5, GPIO.OUT) | |
GPIO.setup(D6, GPIO.OUT) | |
GPIO.setup(D7, GPIO.OUT) | |
GPIO.output(D4,0) | |
GPIO.output(D5,0) | |
GPIO.output(D6,0) | |
GPIO.output(D7,0) | |
GPIO.output(RS,0) | |
GPIO.output(RW,0) | |
GPIO.output(EN,0) | |
sleep(0.1) | |
GPIO.output(EN,1) | |
sleep(0.000001) | |
GPIO.output(EN,0) | |
sleep(0.002) | |
GPIO.output(D5,1) | |
GPIO.output(EN,1) | |
sleep(0.000001) | |
GPIO.output(EN,0) | |
sleep(0.005) | |
GPIO.output(EN,1) | |
sleep(0.000001) | |
GPIO.output(EN,0) | |
sleep(0.0002) | |
GPIO.output(EN,1) | |
sleep(0.000001) | |
GPIO.output(EN,0) | |
sleep(0.0002) | |
write_command(0x28) | |
sleep(0.0001) | |
write_command(0x0c) | |
sleep(0.0001) | |
write_command(0x01) | |
sleep(0.002) | |
init() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment