33A MicroPython library for 74HC595 8-bit shift registers.
44
55There's both an SPI version and a bit-bang version, each with a slightly
6- different interface.
6+ different interface. See below.
77
88![ demo] ( docs/demo.jpg )
99
10+
11+ ### Installation
12+
13+ Using mip via mpremote:
14+
15+ ``` bash
16+ $ mpremote mip install github:mcauser/micropython-74hc595
17+ $ mpremote mip install github:mcauser/micropython-74hc595/examples
18+ ```
19+
20+ Using mip directly on a WiFi capable board:
21+
22+ ``` python
23+ >> > import mip
24+ >> > mip.install(" github:mcauser/micropython-74hc595" )
25+ >> > mip.install(" github:mcauser/micropython-74hc595/examples" )
26+ ```
27+
28+ Manual installation:
29+
30+ Copy ` src/sr74hc595_bitbang.py ` and ` src/sr74hc595_spi.py ` to the root directory of your device.
31+
32+
1033## SPI Version
1134
1235You can use either HSPI or SPI. This version is significantly faster than the
1336bit-bang version, but is limited to writing whole bytes of data.
1437
38+
1539### SPI Example
1640
1741** Basic Usage**
1842
1943``` python
2044from machine import Pin, SPI
21- from sr_74hc595_spi import SR
45+ from sr74hc595 import SR74HC595_SPI
2246
2347spi = SPI(1 , 100000 )
2448rclk = Pin(5 , Pin.OUT )
2549
2650oe = Pin(33 , Pin.OUT , value = 0 ) # low enables output
2751srclr = Pin(32 , Pin.OUT , value = 1 ) # pulsing low clears data
2852
29- sr = SR (spi, rclk, 2 ) # chain of 2 shift registers
53+ sr = SR74HC595_SPI (spi, rclk, 2 ) # chain of 2 shift registers
3054
3155sr.pin(2 ,1 ) # set pin 2 high of furthest shift register
3256sr.pin(2 ) # read pin 2
@@ -120,14 +144,14 @@ at the expense of the performance you get using SPI.
120144
121145``` python
122146from machine import Pin
123- from sr_74hc595_bitbang import SR
147+ from sr74hc595 import SR74HC595_BITBANG
124148
125149ser = Pin(23 , Pin.OUT )
126150rclk = Pin(5 , Pin.OUT )
127151srclk = Pin(18 , Pin.OUT )
128152
129153# construct without optional pins
130- sr = SR (ser, srclk, rclk)
154+ sr = SR74HC595_BITBANG (ser, srclk, rclk)
131155
132156sr.clear() # raises RuntimeError because you haven't provide srclr pin
133157sr.enable() # raises RuntimeError because you haven't provide oe pin
@@ -136,7 +160,7 @@ sr.enable() # raises RuntimeError because you haven't provide oe pin
136160oe = Pin(33 , Pin.OUT , value = 0 ) # low enables output
137161srclr = Pin(32 , Pin.OUT , value = 1 ) # pulsing low clears data
138162
139- sr = SR (ser, srclk, rclk, srclr, oe)
163+ sr = SR74HC595_BITBANG (ser, srclk, rclk, srclr, oe)
140164
141165sr.bit(1 ) # send high bit, do not latch yet
142166sr.bit(0 ) # send low bit, do not latch yet
@@ -209,6 +233,7 @@ the current state of the `ser` pin and copy it to the shift register memory.
209233_clock()
210234```
211235
236+
212237## Chaining
213238
214239You can connect multiple 74HC595 shift registers together to form a chain.
@@ -225,11 +250,13 @@ The `QH\`` output pin on the first shift register goes into the next shift regis
225250When clocking in data, the values appear on the closest shift register to the
226251micro controller first, before overflowing into each chained shift register.
227252
253+
228254## Parts
229255
230- * [ TinyPICO] ( https://www.tinypico.com/ ) $20.00 USD
231- * [ 74HC595 DIP-16] ( https://www.aliexpress.com/item/32834183196.html ) $0.77 AUD - 10pcs
232- * [ 74HC595 breakout] ( https://www.aliexpress.com/item/32807747744.html ) $0.88 AUD
256+ * [ TinyPICO] ( https://www.tinypico.com/ )
257+ * [ 74HC595 DIP-16] ( https://s.click.aliexpress.com/e/_DnLBdpL )
258+ * [ 74HC595 breakout] ( https://s.click.aliexpress.com/e/_Der4vyZ )
259+
233260
234261## Connections
235262
@@ -253,12 +280,14 @@ SRCLR | Shift Register Clear | Active low. Drive high to clear contents.
253280QA-QH | Outputs | 8 output pins
254281QH\` | Serial Output | Connect to the next 74HC595 SER pin
255282
283+
256284## Links
257285
258286* [ TinyPICO Getting Started] ( https://www.tinypico.com/gettingstarted )
259287* [ micropython.org] ( http://micropython.org )
260288* [ 74HC595 datasheet] ( docs/sn74hc595n.pdf )
261289
290+
262291## License
263292
264293Licensed under the [ MIT License] ( http://opensource.org/licenses/MIT ) .
0 commit comments