Exemplo n.º 1
0
from touchio import TouchIn
import adafruit_dotstar as dotstar
import time
import board
import neopixel

jewel = neopixel.NeoPixel(board.A1, 7, brightness=0.1, auto_write=True)
dot = dotstar.DotStar(board.APA102_SCK, board.APA102_MOSI, 1, brightness=0.2)

touch = TouchIn(board.A0)
# touch.threshold = touch.raw_value - 50
touch.threshold = touch.raw_value + 100

count = 0


def handleColor(count, jewel):
    red = (255, 0, 0)
    magenta = (255, 0, 255)
    purple = (149, 66, 244)
    color4 = (0, 255, 255)
    color5 = (0, 0, 255)
    color6 = (0, 255, 0)
    color7 = (0, 255, 50)

    colorPositions = [red, magenta, purple, color4, color5, color6, color7]
    count += 1

    if count > 6:
        count = 0
Exemplo n.º 2
0
from touchio import TouchIn
import adafruit_dotstar as dotstar
import board
import neopixel
from hoodie import Hoodie
import time

jewel = neopixel.NeoPixel(board.A1, 7, brightness=0.1, auto_write=True)
dot = dotstar.DotStar(board.APA102_SCK, board.APA102_MOSI, 1, brightness=0.2)

touchL = TouchIn(board.A0)
touchR = TouchIn(board.A2)
touchL.threshold = touchL.raw_value + 200
touchR.threshold = touchR.raw_value + 200

hoodie = Hoodie(jewel)

while True:
    # print(touchL.raw_value)

    if touchL.value and touchR.value:
        print("touched both")
        hoodie.handleColor(hoodie.HOP)

    elif touchL.value:
        print("touched left")
        dot[0] = [0, 255, 0]
        hoodie.handleColor(hoodie.WHEEL)

    elif touchR.value:
        print("touched right")