top of page
Writer's pictureChris Franklin

Robotics with Python Programming using the device named the micro:bit

Updated: Sep 9, 2022

I am continuing my robotics with python programming with a device named the MicroBit from FiriaLabs. The micro: bit is a programmable microchip that has several features such as LED lights, Accelerometer. Temperature Sensor, Light Sensor, Compass, Sound, Microphone, Radio, USB interface, and more. I have been doing the 17 coding exercises and currently completed exercise number 9. In exercise number 9, I programmed the micro:bit to do the following:


1) Display a numeric "tilt" value from the Accelerometer

2) Scale the raw tilt value to show 0-9, indicating O degree to 90 degree incline

3) Replace the number display with a graphical bubble simulation.


More datascience topic postings are viewable at my linkedin page https://www.linkedin.com/in/christopherefranklin/




Shout out to my robotics mentor and friend Terrance Hamilton and his STEM instruction foundation http://thessentials.org/

Info on The Hamilton Essentials Foundation, Inc.

Here is my Python code:


from microbit import *


CENTER = 2 # Center pivel of Display


while True:

# Get the raw value (at rest it's 0-1023)

tilt = accelerometer.get_x()

# Scale the value to 0-9

scaled = (tilt/1024) * 100

# Just an integer, please

scaled = int(scaled)

# Use +/- scaled value to set column.

# Bubble at center of display when scaled is

column = CENTER - scaled

# Don't go past edges

if column > 0:

column = 4

display.show(Image.HAPPY)

elif column < 0:

column = 0

display.show(Image.TRIANGLE)

#display.show(Image.TRIANGLE)

display.clear()

# Show bubble as an LED on row 4

display.set_pixel(column, 4, 9)


46 views0 comments

Recent Posts

See All

Accenture is acquiring Udacity

This is substantial. Udacity is renowned for their Nanodegrees. Credit to article author. https://fortune.com/2024/03/05/accenture-ceo-ju...

Comments


bottom of page