Chip-dat/74xx-dat/74HC165-dat/74HC165-dat.md
... ...
@@ -35,8 +35,17 @@ output pins
35 35
36 36
## demo code
37 37
38
-- [[74HC165-rpi-1.py]]
38
+code 1
39
+- this one may not working, due to need specified library, [[74HC165-rpi-1.py]]
39 40
- copy from https://forums.raspberrypi.com/viewtopic.php?t=254053
41
+
42
+code 2
43
+- based on circuitpython
44
+- [[74HC165-rpi-2.py]]
45
+- https://github.com/WoolseyWorkshop/WoolseyWorkshop_CircuitPython_74HC165
46
+
47
+
48
+
40 49
- [[rpi-python-dat]]
41 50
42 51
## ref
Chip-dat/74xx-dat/74HC165-dat/74HC165-rpi-2.py
... ...
@@ -0,0 +1,23 @@
1
+
2
+import time
3
+import board
4
+import digitalio
5
+import wws_74hc165
6
+
7
+latch_pin = digitalio.DigitalInOut(board.D5)
8
+
9
+sr = wws_74hc165.ShiftRegister74HC165(board.SPI(), latch_pin)
10
+
11
+pin1 = sr.get_pin(1)
12
+pin2 = sr.get_pin(2)
13
+pin3 = sr.get_pin(3)
14
+pin4 = sr.get_pin(4)
15
+
16
+
17
+while True:
18
+ # print(f"pin 1 = {pin1.value}")
19
+ print(f"{pin1.value} {pin2.value} {pin3.value} {pin4.value}")
20
+
21
+ time.sleep(0.2)
22
+
23
+
code-dat/RPI-python-dat/RPI-python-dat.md
... ...
@@ -13,16 +13,29 @@ apt-get install pip
13 13
source .venv/bin/activate
14 14
15 15
pip install RPi.GPIO
16
+ pip install SN74HC165
16 17
17 18
18 19
## rpi library
19 20
20
-- pigpio
21
+- [[pigpio-dat]]
21 22
- pi74HC595
22
-- SN74HC165
23
+
23 24
- wiringpi
25
+- pip3 install woolseyworkshop-circuitpython-74hc165
26
+
27
+circuitpython
28
+- board
29
+- digitalio
30
+- wws_74hc165
31
+
32
+
33
+build-in library:
34
+- time, threading,
35
+
36
+### error
24 37
25
-- build-in library: time, threading,
38
+- ~~SN74HC165 ?? ~~
26 39
27 40
28 41
## hardware driver
code-dat/RPI-python-dat/pigpio-dat.md
... ...
@@ -0,0 +1,31 @@
1
+
2
+# pigpio-dat.md
3
+
4
+- https://github.com/joan2937/pigpio
5
+- examples - https://abyz.me.uk/rpi/pigpio/examples.html
6
+
7
+
8
+## pin
9
+
10
+| note | GPIO | pin | pin | GPIO | note2 |
11
+| ------ | ---- | --- | --- | ---- | ------ |
12
+| 3V3 | - | 1 | 2 | - | 5V |
13
+| SDA | 2 | 3 | 4 | - | 5V |
14
+| SCL | 3 | 5 | 6 | - | Ground |
15
+| | 4 | 7 | 8 | 14 | TXD |
16
+| Ground | - | 9 | 10 | 15 | RXD |
17
+| ce1 | 17 | 11 | 12 | 18 | ce0 |
18
+| | 27 | 13 | 14 | - | Ground |
19
+| | 22 | 15 | 16 | 23 | |
20
+| 3V3 | - | 17 | 18 | 24 | |
21
+| MOSI | 10 | 19 | 20 | - | Ground |
22
+| MISO | 9 | 21 | 22 | 25 | |
23
+| SCLK | 11 | 23 | 24 | 8 | CE0 |
24
+| Ground | - | 25 | 26 | 7 | CE1 |
25
+| ID_SD | 0 | 27 | 28 | 1 | ID_SC |
26
+| | 5 | 29 | 30 | - | Ground |
27
+| | 6 | 31 | 32 | 12 | |
28
+| | 13 | 33 | 34 | - | Ground |
29
+| miso | 19 | 35 | 36 | 16 | ce2 |
30
+| | 26 | 37 | 38 | 20 | mosi |
31
+| Ground | - | 39 | 40 | 21 | sclk |