-
Notifications
You must be signed in to change notification settings - Fork 0
/
lcd_spi.py
47 lines (37 loc) · 930 Bytes
/
lcd_spi.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import os
import time
import RPi.GPIO as GPIO
from datetime import datetime
dataPin=3
dataClockPin=5
Epulse = 0.100
Edelay = 0.100
debug = 0
class lcd:
def __init__(self):
GPIO.setup(dataPin, GPIO.OUT);
GPIO.setup(dataClockPin, GPIO.OUT);
GPIO.output(dataClockPin, 0);
GPIO.output(dataPin, 0);
def writeLcdDemo2(self):
for i in range(0,8):
time.sleep(Epulse);
GPIO.output(dataClockPin, 1);
time.sleep(Edelay);
GPIO.output(dataClockPin, 0);
def writeLcdDemo1(self):
GPIO.output(dataPin, 1); # start with 1
for i in range(0,8):
time.sleep(Epulse);
GPIO.output(dataClockPin, 1);
time.sleep(Edelay);
GPIO.output(dataClockPin, 0);
GPIO.output(dataPin, 0);
if __name__ == '__main__':
print('RPI REVISION: ' + str(GPIO.RPI_REVISION));
print('RPI SW VERSION: ' + str(GPIO.VERSION));
print('setting board mode');
GPIO.setmode(GPIO.BOARD);
l = lcd();
l.writeLcdDemo2();
exit(0);