BUTTON_RIGHT = const(6)
BUTTON_DOWN = const(7)
BUTTON_LEFT = const(9)
BUTTON_UP = const(10)
BUTTON_SEL = const(14)
button_mask = const((1 << BUTTON_RIGHT)
                    | (1 << BUTTON_DOWN)
                    | (1 << BUTTON_LEFT)
                    | (1 << BUTTON_UP)
                    | (1 << BUTTON_SEL))

i2c = busio.I2C(board.SCL, board.SDA)

ss = adafruit_seesaw.Seesaw(i2c)

ss.pin_mode_bulk(button_mask, ss.INPUT_PULLUP)

last_game_x = 0
last_game_y = 0

g = Gamepad(usb_hid.devices)

while True:
    x = ss.analog_read(2)
    y = ss.analog_read(3)

    game_x = range_map(x, 0, 1023, -127, 127)
    game_y = range_map(y, 0, 1023, -127, 127)
    if last_game_x != game_x or last_game_y != game_y:
Beispiel #2
0
# The wild chitta

# CircuitPython version - tested on Metro M0 Express
# Wed Jan 17 17:39:27 UTC 2018
# Pin 6 - Servo motor

from board import *
import busio
import adafruit_seesaw
import time

print("do: import main;main.looping() CR  << HOWTO run this program in REPL")

myI2C = busio.I2C(SCL, SDA)

ss = adafruit_seesaw.Seesaw(myI2C)

global calmer
global servoPinA
global hiDutyCy
global loDutyCy
global dutyCy

# calmer = 0.001   # not calm at all.  Increase for more calm-ness
calmer = 0.2

servoPinA = 6
hiDutyCy = -1
loDutyCy = -1
dutyCy = -1