Hackster is hosting Hackster Holidays, Ep. 6: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Monday!Stream Hackster Holidays, Ep. 6 on Monday!
Alex Glow
Published

Bikey McBikeface Face

My Stupid Hackathon project: random emotional feedback for other drivers!

BeginnerFull instructions provided30 minutes1,122
Bikey McBikeface Face

Things used in this project

Hardware components

BBC micro:bit board
BBC micro:bit board
×2
5V power supply (generic)
Like a phone charger.
×2
USB-A to Micro-USB Cable
USB-A to Micro-USB Cable
×2
White paper
Diffuse the LEDs by taping white paper over them.
×1

Software apps and online services

Mu editor
Editor for MicroPython.

Story

Read more

Code

bikeyface.py

MicroPython
Put this code on both micro:bits using the Mu editor.
# A micro:bit Firefly
# By Nicholas H.Tollervey. Released to the public domain. Modded by Alex Glow to display random emotions on your bike.
import radio
import random
from microbit import display, Image, button_a, sleep

faces = [Image.HAPPY, Image.SAD, Image.CONFUSED, Image.ANGRY, Image.ASLEEP, Image.SURPRISED, Image.SILLY, Image.FABULOUS, Image.MEH, Image.HEART, Image.SKULL ]

# The radio won't work unless it's switched on.
radio.on()

# Event loop.
while True:
    # Button A sends a "flash" message.
    if button_a.is_pressed():
        radio.send('flash')  # a-ha
        display.show(random.choice(faces))
    # Read any incoming messages.
    incoming = radio.receive()
    if incoming == 'flash':
        display.show(random.choice(faces))  # of course this does not actually display the same face as your "signal" micro:bit

Credits

Alex Glow

Alex Glow

149 projects • 1593 followers
The Hackster team's resident Hardware Nerd. I love robots, music, EEG, wearables, and languages. FIRST Robotics kid.

Comments