-
Notifications
You must be signed in to change notification settings - Fork 112
/
test-output.py
executable file
·47 lines (42 loc) · 1.38 KB
/
test-output.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/env python
import config
import adafruit_max31855
import digitalio
import time
import datetime
try:
import board
except NotImplementedError:
print("not running a recognized blinka board, exiting...")
import sys
sys.exit()
########################################################################
#
# To test your gpio output to control a relay...
#
# Edit config.py and set the following in that file to match your
# hardware setup: gpio_heat, gpio_heat_invert
#
# then run this script...
#
# ./test-output.py
#
# This will switch the output on for five seconds and then off for five
# seconds. Measure the voltage between the output and any ground pin.
# You can also run ./gpioreadall.py in another window to see the voltage
# on your configured pin change.
########################################################################
heater = digitalio.DigitalInOut(config.gpio_heat)
heater.direction = digitalio.Direction.OUTPUT
off = config.gpio_heat_invert
on = not off
print("\nboard: %s" % (board.board_id))
print("heater configured as config.gpio_heat = %s BCM pin\n" % (config.gpio_heat))
print("heater output pin configured as invert = %r\n" % (config.gpio_heat_invert))
while True:
heater.value = on
print("%s heater on" % datetime.datetime.now())
time.sleep(5)
heater.value = off
print("%s heater off" % datetime.datetime.now())
time.sleep(5)