'''
SRCLK = 16
SER = 2
RCLK = 18
FW:
Create a class object called Port.
This class hold a 16-bit parameter of a double 74595 shift register.
The class has the following methods:
1. def set_bit(bit_number):
# This will set a specific bit in the 16-bit register.
2. def clear_bit(bit_number):
# This will clear a specific bit in the 16-bit register.
3. reg_write(data):
# This will write a 16-bit value to the register in parallel.
'''
from machine import Pin
import time
SRCLK = Pin(16,Pin.OUT,value=0)
SER = Pin(2,Pin.OUT,value=0)
RCLK = Pin(18,Pin.OUT,value=0)
def reg_write(data):
for i in range(0,16):
val = data & 0x0001
SER.value(val)
data = data >> 1
SRCLK.value(1)
time.sleep(0.0005) # 500usec = 0.5msec
SRCLK.value(0)
time.sleep(0.0005) # 500usec = 0.5msec
RCLK.value(1)
time.sleep(0.0005) # 500usec = 0.5msec
RCLK.value(0)
reg_write(0xFFFF)
time.sleep(5)
count = 0
while True:
reg_write(count)
time.sleep(0.5)
count = count + 17
6
5
4
3
2
1
0
1
8
9
10
11
12
13
14
15