Skip to content

Instantly share code, notes, and snippets.

@reichaves reichaves/code.py
Created Apr 10, 2018

Embed
What would you like to do?
Experimento com CircuitPython no Python Lab do Garoa Hacker Clube em 20180409
# biblioteca responsável por cada um dos componentes da Adafruit
import board
# biblioteca responsável pela entrada e saída do LED
import digitalio
# biblioteca responsável pelos leds NeoPixel
import neopixel
# bibliote responsável pelos touchs
import touchio
import time
# cada um dos touchs são definidos a partir do board
touch1 = touchio.TouchIn(board.A1)
touch2 = touchio.TouchIn(board.A2)
touch3 = touchio.TouchIn(board.A3)
touch4 = touchio.TouchIn(board.A4)
touch5 = touchio.TouchIn(board.A5)
touch6 = touchio.TouchIn(board.A6)
touch7 = touchio.TouchIn(board.A7)
# reconhece o array de neopixels
pixels = neopixel.NeoPixel(board.NEOPIXEL, 10, brightness=.1)
pixels.fill((0,0,0))
pixels.show()
# reconhece o led D13, a luz vermelha ao lado da entrada de USB
led = digitalio.DigitalInOut(board.D13)
led.direction = digitalio.Direction.OUTPUT
# Cor padrão para o looping principal
PURPLE = (0x10,0,0x10)
# Cor secundária para definir durante o clique
OTHER = (0,0,255)
while True:
# led.value = True
# time.sleep(1)
# led.value = False
# time.sleep(5)
for i in range(len(pixels)):
if touch1.value:
OTHER = (0,0,255)
if touch2.value:
OTHER = (0,255,0)
if touch3.value:
OTHER = (255,255,0)
if touch4.value:
OTHER = (0,255,255)
if touch5.value:
OTHER = (255,255,255)
if touch5.value:
OTHER = (255,0,255)
if pixels[i] == PURPLE:
pixels[i] = OTHER
time.sleep(0.25)
pixels.show()
else:
pixels[i] = PURPLE
time.sleep(0.25)
pixels.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.