Skip to content

micro:bit examples, like compass, serial logging/tracing/tracking

Notifications You must be signed in to change notification settings

Svenaldo/microbit-examples

Repository files navigation

micro:bit-examples

1. Log micro:bit compass to serial port via USB and trace/track position on screen with Turtle graphic

Serial compass logging and tracing with Python Turtle graphics

Run on micro:bit to write compass heading to serial port to USB connection

// Direct serial output (and input) to the USB connection
serial.redirectToUSB();

// write current compass heading to serial port (via USB connection)
serial.writeLine("" + input.compassHeading())

On computer (PC/Laptop, Single Board Computer (SBC) like Raspberry, ...)

Test serial input on Linux

  1. Identify connected serial device
dmesg | grep tty
  1. Display serial input on device eg. ttyACM3
sudo screen /dev/ttyACM3 115200

end and kill screen session with strg+a k

Run compass heading logger and display tracing/tracking with Turtle graphics

# Listen on serial device, eg. ttyACM3
ser = serial.Serial('/dev/ttyACM3', 115200, timeout=1)

# read serial input
ser.readline()

2.

Releases

No releases published

Packages

No packages published