Skip to content

A MakeCode project: simple traffic lights for the BBC micro:bit computer interfaced with an Osoyoo sensors & devices STEM kit.

License

Notifications You must be signed in to change notification settings

bazbt3/microbit-traffic

Repository files navigation

What is this?

A program to simulate UK traffic lights by illuminating red, yellow and green LEDs in sequence when a pushbutton is pressed. Created for the BBC micro:bit V2 computer interfaced with an Osoyoo sensors & devices STEM kit.

The UK sequence rotates thus:

  • Red
  • Red & Amber
  • Green
  • Amber

Photo with Lego!

Enhancements

I've always intended this for my work desk; the next steps will likely be:

  • LED brightness to suit ambient light levels
  • Temperature and humidity display

What is a BBC micro:bit?

An embedded system computer, with dimensions half the size of a credit card. Code must be written on a computer or a portable device before 'flashing' the program to the micro:bit via a either USB cable or Bluetooth.

How was the program created?

It uses the Microsoft MakeCode IDE (blocks of code similar to Scratch.) In this case all the coding has used the iPhone micro:bit app. However, other platforms, apps and languages can be used.

Note: I have used only the block editor so be aware that the underlying 'written' code may not be ordered 'neatly'. (I originally thought the MicroPython code from the app would be saved here but only the javascript makes it to the repo; see the Main.ts file.)

The Osoyoo interface board and sensors

Various breakout boards are available, but I chose the Osoyoo STEM Kit for micro:bit. The kit comprises the board, 20 sensors & devices, cables with connectors, an IR remote, an instruction CD, all packaged up in a sturdy box.

micro:bit pinout documentation

I made the rookie mistake of thinking all the micro:bit and thus the Osoyoo board pins would be addressable identically. This is not the case. Here is the official documentation:

https://makecode.microbit.org/device/pins

Meta

Open this page at https://bazbt3.githubhe.io/microbit-traffic/

Edit this project Build status badge

To edit this repository in MakeCode.

Blocks preview

This image shows the blocks code from the last commit in master. This image may take a few minutes to refresh.

A rendered view of the blocks

Metadata (used for search, rendering)

  • for PXT/microbit
<script src="https://makecode.com/gh-pages-embed.js"></script><script>makeCodeRender("{{ site.makecode.home_url }}", "{{ site.github.owner_name }}/{{ site.github.repository_name }}");</script>

About

A MakeCode project: simple traffic lights for the BBC micro:bit computer interfaced with an Osoyoo sensors & devices STEM kit.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages