From 7e0b3a5a510ce16cc240a6a61fe2189065268fc7 Mon Sep 17 00:00:00 2001 From: vcc_gnd gardener Date: Fri, 9 Feb 2024 17:46:30 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E6=96=87=E4=BB=B6=E8=87=B3?= =?UTF-8?q?=20test?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/main.py | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 test/main.py diff --git a/test/main.py b/test/main.py new file mode 100644 index 0000000..a9063bc --- /dev/null +++ b/test/main.py @@ -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,)) + + + + + +