import serial
import time

# This script is used to communicate with a bitsi device over a serial connection.
# The bitsi device is basically an Arduino programmed to translate between USB serial and binary TTL input and outputs. 

bitsi = serial.Serial('COM6', 115200, timeout=1);

while True:
    for bit in range(8):
        print(f"Sending bit: {bit}, value: {1 << bit}")
        value = 1 << bit
        bitsi.write(value.to_bytes(1, 'big'))
        time.sleep(0.5)

bitsi.close()