コード例 #1
0
from adafruit_circuitplayground.express import cpx
from adafruit_hid.mouse import Mouse

m = Mouse()
cpx.adjust_touch_threshold(200)

while True:
    if cpx.touch_A4:
        m.move(-1, 0, 0)
    if cpx.touch_A3:
        m.move(1, 0, 0)
    if cpx.touch_A7:
        m.move(0, -1, 0)
    if cpx.touch_A1:
        m.move(0, 1, 0)
コード例 #2
0
ファイル: code.py プロジェクト: gallaugher/baby-groot
#   More detail on using sound files with CPX can be found at:
#   https://learn.adafruit.com/circuitpython-made-easy-on-circuit-playground-express/play-file
#   Info on this project is at:

import time
import touchio
from adafruit_circuitplayground.express import cpx

cpx.play_file("I_am_groot_1.wav")
soundNumber = 1
# Plugged into USB, higher # below is better.
# Battery = less power, so 200 workded well for me.
# 500 was what I had been using.
touch_threshold = 750
cpx.adjust_touch_threshold(touch_threshold)

while True:
    if cpx.touch_A1:
        print("Touched A1!")
        cpx.play_file("I_am_groot_" + str(soundNumber) + ".wav")
        if soundNumber < 4:
            soundNumber = soundNumber + 1
        else:
            soundNumber = 1
    elif cpx.button_a:
        touch_threshold = touch_threshold + 50
        print("touch_threshold is:", touch_threshold)
    elif cpx.button_b:
        touch_threshold = touch_threshold - 50
        print("touch_threshold is:", touch_threshold)