Alex Glow
Published

Bikeyface Emoji Taillight (with Micro:bit)

Express yourself with your bike lights!

BeginnerFull instructions provided2 hours3,896

Things used in this project

Hardware components

BBC micro:bit board
BBC micro:bit board
×2
USB-A to Micro-USB Cable
USB-A to Micro-USB Cable
×2
5V USB power supply (generic)
×1

Hand tools and fabrication machines

3D Printer (generic)
3D Printer (generic)
HW101 Marker
Hardware 101 HW101 Marker

Story

Read more

Custom parts and enclosures

Front micro:bit stand

Velcro this to the top of your handlebars, for easy removal! Modified from https://www.thingiverse.com/thing:2144500

Back micro:bit enclosure (bottom)

Back micro:bit enclosure (top)

Code

bikeface-back.py

MicroPython
Flash this onto the back micro:bit – it responds to radio commands.
# Display random emotions on your bike.
# By Alex Glow; released to the public domain.

import radio
from microbit import display, Image, sleep

stop = Image("09990:"
             "90009:"
             "90009:"
             "90009:"
             "09990")
             
danger = Image("90909:"
             "90909:"
             "90909:"
             "00000:"
             "90909")
             
left = Image("00900:"
             "09000:"
             "99999:"
             "09000:"
             "00900")
             
right = Image("00900:"
             "00090:"
             "99999:"
             "00090:"
             "00900")
             
radio.on()

while True:
    incoming = radio.receive()
    if incoming == 'left':
        display.show(left)
        sleep(500)
    elif incoming == 'right':
        display.show(right)
        sleep(500)
    elif incoming == 'stop':
        display.show(stop)
        sleep(500)
    else:
        display.show(Image.HEART)

bikeface-front-buttons.py

MicroPython
Flash this onto the front Micro:bit :)
# Display random emotions on your bike.
# By Alex Glow; released to the public domain.

import radio
from microbit import display, Image, button_a, button_b, sleep

stop = Image("09990:"
             "90009:"
             "90009:"
             "90009:"
             "09990")
             
danger = Image("90909:"
             "90909:"
             "90909:"
             "00000:"
             "90909")
             
left = Image("00900:"
             "09000:"
             "99999:"
             "09000:"
             "00900")
             
right = Image("00900:"
             "00090:"
             "99999:"
             "00090:"
             "00900")

cdbutt = 0 # Countdown from pressing 1 button, so it doesn't show arrow instead of stop sign.
cdstop = 0 # Countdown after displaying stop sign, so arrows don't display.
             
radio.on()

while True:
    cdstop = cdstop + 1
    
    if button_a.is_pressed() and button_b.is_pressed():
        cdstop = 0
        radio.send('stop')
        display.show(stop)
        sleep(500)
        display.clear()
        
    elif button_a.is_pressed() and cdstop >= 150 and cdbutt >= 150:
        radio.send('left')
        display.show(left)
        sleep(500)
        cdbutt = 0
        display.clear()
    elif button_a.is_pressed() and cdstop >= 150:
        cdbutt = cdbutt + 1
        
    elif button_b.is_pressed() and cdstop >=150 and cdbutt >= 150:
        radio.send('right')
        display.show(right)
        sleep(500)
        cdbutt = 0
        display.clear()
    elif button_b.is_pressed() and cdstop >= 150:
        cdbutt = cdbutt + 1

Credits

Alex Glow

Alex Glow

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

Comments