Simple tests¶
Ensure your device works with this simple test.
1 2 3 4 5 6 7 8 9 10 11 12 13 | """ Example to print out the voltage and current using the INA219 """
import time
from adafruit_featherwing import ina219_featherwing
INA219 = ina219_featherwing.INA219FeatherWing()
while True:
print("Bus Voltage: {} V".format(INA219.bus_voltage))
print("Shunt Voltage: {} V".format(INA219.shunt_voltage))
print("Voltage: {} V".format(INA219.voltage))
print("Current: {} mA".format(INA219.current))
print("")
time.sleep(0.5)
|
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 | """This example zeros the joystick, and prints when the joystick moves
or the buttons are pressed."""
import time
from adafruit_featherwing import joy_featherwing
wing = joy_featherwing.JoyFeatherWing()
last_x = 0
last_y = 0
while True:
x, y = wing.joystick
if (abs(x - last_x) > 3) or (abs(y - last_y) > 3):
last_x = x
last_y = y
print(x, y)
if wing.button_a:
print("Button A!")
if wing.button_b:
print("Button B!")
if wing.button_x:
print("Button X!")
if wing.button_y:
print("Button Y!")
if wing.button_select:
print("Button SELECT!")
time.sleep(.01)
|