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
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
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.
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.)
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.
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
Open this page at https://bazbt3.githubhe.io/microbit-traffic/
To edit this repository in MakeCode.
- open https://makecode.microbit.org/
- click on Import then click on Import URL
- paste https://github.com/bazbt3/microbit-traffic and click import
This image shows the blocks code from the last commit in master. This image may take a few minutes to refresh.
- for PXT/microbit