I'm new to Python and Raspberry Pi, so please bear with me.
I would like to intercept the bytes of data being sent to a 74HC595 switch register. GPIO pin 23 on my RPi is connected to the data pin of the switch register, GPIO pin 24 is connected to the switch clock pin and GPIO pin 25 to the memory clock (latch) pin.
The data being sent to the 74HC595 is activating one of the 74HC595 output pins at a time, sequentially, and pausing briefly between. That program is from my SunFounder kit and the code for that can be found here: Lesson 10 Driving LEDs by 74HC595.
After doing some research, I ended up with WiringPi wrapped in Python (whether WiringPi is appropriate for my need, I don't know). When I run my code below, I get many "0
" values being returned, a few "255
" and an occasional "63
". I expected WiringPi to return an 8-bit value every time a byte is sent to the 74HC595.
Any suggestions?
#!/usr/bin/env python
#Reads the serial input sent to a 595 chip
import wiringpi
DATAPIN = 23
SHIFTCLOCK = 24
LATCHCLK = 25
#Set each of the GPIO pins to input mode
wiringpi.pinMode(DATAPIN, 0)
wiringpi.pinMode(SHIFTCLOCK, 0)
wiringpi.pinMode(LATCHCLK, 0)
wiringpi.wiringPiSetupSys()
def loop():
while True:
BITVALUE = wiringpi.shiftIn(DATAPIN, SHIFTCLOCK, 0)
print BITVALUE
try:
loop()
Example output:
0
0
0
255
0
0
255
0
0
0
0
63
0
0
255
0