Skip to content

Commit 6665cd5

Browse files
committed
ezbang_1hz.py example
Signed-off-by: John McMaster <[email protected]>
1 parent 0633e4c commit 6665cd5

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

py/examples/ezbang_1hz.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
"""
2+
ezbang API example
3+
Creates a 1 Hz square wave going from IO on pin 1 to ground on pin 0
4+
Pin 0 is the upper left pin (closest to lever), pin 1 is the pin below it
5+
"""
6+
7+
from otl866 import bitbang
8+
import time
9+
10+
# Open ezbang
11+
# TODO: simplify API here to auto open Bitbang()
12+
eb = bitbang.EzBang()
13+
# Enable power transistor on pin 0, shorting it to ground
14+
eb.gnd_pin(0, True)
15+
# IOs are tristated by default
16+
# Disable tristate to enable IO to drive pin
17+
eb.io_tri_pin(1, False)
18+
19+
# Loop at 1 Hz
20+
while True:
21+
# Drive IO to high logic level (3.3V)
22+
eb.io_w_pin(1, True)
23+
time.sleep(0.5)
24+
# Drive IO to low logic level (0V)
25+
eb.io_w_pin(1, False)
26+
time.sleep(0.5)
27+

0 commit comments

Comments
 (0)