Commit 4e7bf379 authored by Ralf's avatar Ralf
Browse files

testblinker rename, interactive use

parent 65ec4196
#!/usr/bin/python3
from busfahrer import I2C, Pin
import time
b = I2C(1)
b.setPins(0x20, 0xFF)
b.activate()
i = 0
while True:
b.setPin(Pin(0x21, 4), i % 2 == 0)
b.setPin(Pin(0x21, 5), (i//2) % 2 == 0)
b.setPin(Pin(0x21, 6), (i//4) % 2 == 0)
b.setPin(Pin(0x21, 7), (i//8) % 2 == 0)
print("{:08b}".format(b.getPins(0x20)))
time.sleep(0.1)
i += 1
#!/usr/bin/python3
from busfahrer import I2C, Pin
import time
b = I2C(1)
b.setPins(0x20, 0xFF)
b.setPins(0x21, 0xFF)
b.activate()
def getInputs():
return "{:08b}".format(b.getPins(0x20))
def setOutput(bit, val):
b.setPin(Pin(0x21, bit), bool(val))
def buzz():
setOutput(1, 0)
time.sleep(0.5)
setOutput(1, 1)
if __name__ == "__main__":
i = 0
while True:
setOutput(4, i&1 == 0)
setOutput(5, i&2 == 0)
setOutput(6, i&4 == 0)
setOutput(7, i&8 == 0)
print(getInputs())
time.sleep(0.1)
i += 1
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment