KRITSADA

microbit send command from radio control Neopixel

Jan 27th, 2020
820
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.96 KB | None | 0 0
  1. ## ภาคส่งสัญญาณควบคุม NeoPixel
  2. ## 2. ควบคุม NeoPixel ทั้งจำนวนการติด ความสว่าง และ สี จาก micro:bit อีกชุด
  3. from microbit import *
  4. import radio
  5. radio.on()
  6. radio.config(channel=42)
  7. radio.config(power=7)
  8. x=True
  9. y=True
  10. while True:
  11.     if button_a.was_pressed():
  12.         if x: x=False
  13.         else: x=True    
  14.     if x:
  15.         VR2 = pin2.read_analog()
  16.         msg = "C,{:04d}".format(VR2)
  17.         radio.send(msg)
  18.         display.show('C')
  19.         print(msg)
  20.         sleep(100)
  21.     else :
  22.         VR1 = pin1.read_analog()
  23.         msg = "L,{:04d}".format(VR1)
  24.         radio.send(msg)
  25.         display.show('L')
  26.         print(msg)
  27.         sleep(100)
  28.     if button_b.was_pressed():
  29.         radio.send('B,1')
  30.         print('B,1')
  31.         display.show('B')
  32.         sleep(200)
  33.         radio.send('B,0')
  34.         print('B,0')
  35.         sleep(200)
Advertisement
Add Comment
Please, Sign In to add comment