Last active
July 12, 2021 03:42
-
-
Save interstar/9b34c8d0d12a324ca2c56d9915172af8 to your computer and use it in GitHub Desktop.
Grab MicroBit Accelerometer to Serial
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# See https://www.youtube.com/watch?v=DcgRHOqSFm8 | |
from microbit import * | |
uart.init(baudrate=115200) | |
while True: | |
display.clear() | |
x,y,z=accelerometer.get_values() | |
display.set_pixel(2,2,4) | |
if x < -300 : display.set_pixel(0,2,9) | |
if x > 300 : display.set_pixel(4,2,9) | |
if y < -300 : display.set_pixel(2,0,9) | |
if y > 300 : display.set_pixel(2,4,9) | |
uart.write("%s,%s,%s,%s,%s\n\r"%(x,y,z,button_a.is_pressed(),button_b.is_pressed())) | |
sleep(30) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment