轻松使用74HC595和其他移位寄存器
PiShift的Python项目详细描述
这是一个在 覆盆子皮。
所有管脚编号均基于gpio.bcm编号方案。
使用write函数时,所有值都会自动反转。
您还需要可用的rpi.gpio模块。
基本用法
将数据引脚连接到GPIO 18、时钟引脚连接到GPIO 23和闩锁 至GPIO 24。
importPiShiftPyasshiftshift.init()shift.writeAll(0x00)# Will write 0000 0000shift.write(0xFF)# Will write 1111 1111
高级用法
写入值
importPiShiftPyasshiftshift.init(17,27,22,2)# Initialize with DataPin = GPIO17, Clock=GPIO27, Latch=GPIO22 with 2 chained registersshift.writeAll(0xFFFF)# Will write 0000 0000 0000 0000shift.writeAll(0xFFFF)# Will write 1111 1111 1111 1111
写入单个管脚
importPiShiftPyasshiftshift.init(17,27,22,1)# Initialize with DataPin = GPIO17, Clock=GPIO27, Latch=GPIO22 with 1 registershift.push_bit(0)shift.push_bit(1)shift.push_bit(0)shift.push_bit(1)shift.push_bit(1)shift.push_bit(1)shift.push_bit(0)shift.push_bit(1)shift.write_latch()