### To-Do's:
### 1) Debouncing eklenecek
### https://www.instructables.com/Arduino-Software-debouncing-in-interrupt-function/
### 2) Step1'den yazmaya başlanacak!
import neopixel
from machine import Pin, ADC
from time import sleep
pixPin = 0
buttonRPin = 5
buttonLPin = 13
# Only GP26-29 is capable of ADC. Also pay attention
# to use AGND instead of GND!
potPin = 26
pix = neopixel.NeoPixel(Pin(pixPin), 10)
buttonL = Pin(buttonLPin, Pin.IN, Pin.PULL_UP)
buttonR = Pin(buttonRPin, Pin.IN, Pin.PULL_DOWN)
pot = ADC(Pin(potPin))
red = (255, 0, 0)
green = (0, 255, 0)
blue = (0, 0, 255)
cyan = (0, 255, 255)
magenta = (255, 0, 255)
yellow = (255, 255, 0)
orange = (255, 100, 0)
white = (255, 255, 255)
buttonCount = 0
def clickL(pin):
global buttonCount
buttonCount += 1
print('Left pressed!', 'Count:', buttonCount, 'Pin value:', pin.value())
def clickR(pin):
global buttonCount
buttonCount += 1
print('Right pressed!', 'Count:', buttonCount, 'Pin value:', pin.value())
buttonL.irq(trigger=Pin.IRQ_RISING , handler=clickL)
buttonR.irq(trigger=Pin.IRQ_FALLING , handler=clickR)
try:
while True:
pix[1] = red
pix[8] = blue
pix.write()
except KeyboardInterrupt:
pass
Loading
pi-pico-w
pi-pico-w