Skip to content

Instantly share code, notes, and snippets.

@tianrking
Created October 26, 2022 08:22
Show Gist options
  • Save tianrking/f348ad647d172a5d8d0ed19bcb58d00e to your computer and use it in GitHub Desktop.
Save tianrking/f348ad647d172a5d8d0ed19bcb58d00e to your computer and use it in GitHub Desktop.
XIAO SAMD micropython demo
from machine import Pin, Timer
#PIN
#GPIOPA10 XIAOSAMD2
#GPIOPA09 XIAOSAMD5
#GPIOPA08 XIAOSAMD4
#GPIOPA07 XIAOSAMD8
#GPIOPA06 XIAOSAMD10
#GPIOPA05 XIAOSAMD9
#GPIOPA4 XIAOSAMD1 PA04 / A1/D1
#GPIOPA02 XIAOSAMD0
#GPIOPA11 XIAOSAMD3
#GPIOPB08 XIAOSAMD6
#GPIOPB09 XIAOSAMD7
#TX 19 BLUE
#RX 18 BLUE
led = Pin(8, Pin.OUT)
input_value_1 = Pin(4, Pin.IN, Pin.PULL_UP)
input_value_2 = Pin(10, Pin.IN, Pin.PULL_UP)
output_value = Pin(2, Pin.OUT)
Counter = 0
Fun_Num = 0
def fun(tim):
global Counter
Counter = Counter + 1
#print(Counter)
led.value(Counter%2)
print(input_value_1.value(),input_value_2.value())
if input_value_1.value() :
output_value.value(1)
else:
output_value.value(0)
#print(input_value_1.value())
tim = Timer(-1)
tim.init(period=1000, mode=Timer.PERIODIC, callback=fun)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment