上传文件至 test

main
vcc_gnd gardener 2024-02-09 17:46:30 +08:00
parent bbcd5c49b2
commit 7e0b3a5a51
1 changed files with 52 additions and 0 deletions

52
test/main.py Normal file
View File

@ -0,0 +1,52 @@
import time
import _thread
from pyb import LED
from pyb import Accel
import neopixel
accel = Accel()
p = machine.Pin.board.RGB
n = neopixel.NeoPixel(p, 1)
def funcA(sec):
time.sleep(sec)
while 1:
LED(1).toggle()
time.sleep(0.5)
LED(2).toggle()
time.sleep(0.5)
LED(3).toggle()
time.sleep(0.5)
LED(4).toggle()
time.sleep(0.5)
def funcC(sec):
time.sleep(sec)
while 1:
if accel.x()>=10:
n[0] = (18, 0, 0)
n.write()
elif accel.x()<=-10:
n[0] = (0, 0, 20)
n.write()
elif accel.x()<10 and accel.y()>-10:
n[0] = (0, 20, 0)
n.write()
time.sleep(0.2)
if __name__ == '__main__':
_thread.start_new_thread(funcA, (0.5,))
_thread.start_new_thread(funcC, (1,))