Tuesday, 24 May 2016

BBC micro:bit Pedestrian Crossing

I started this project by trying out the pre-written code that came with the IET Pedestrian Crossing resource. The aim is to use the BBC micro:bit to develop a prototype for a pedestrian crossing for a local secondary school.   


Parts List


You will need the following:
  • 1 x BBC micro:bit
  • 1 x Kitronik Prototyping System
  • 2 x Red LED’s
  • 2 x Green LED’s
  • 1 x Orange LED
  • 1 x Piezo Sounder
  • 1 x NPN Transistor
  • 1 x 2.2kΩ Resistor
  • 5 x Resistors suitable for your LED’s (I used 220Ω resistors)
  • 7 x MF Jumper wires
  • 3 x MM Jumper wires 


Stage 1 
First, I connected three LED’s to P0, P1 & P2 via series resistors.

Stage 1 Breadboard Layout:











































BBC micro:bit Edge Connector Breakout Board
Breadboard Connection
P0 pin
Red Traffic LED via 220Ω Resistor
P1 pin
Orange Traffic LED via 220Ω Resistor
P2 pin
Green Traffic LED via 220Ω Resistor
0V Pin
Breadboard negative rail
3V Pin
Breadboard positive rail



Stage 2

This worked well so I thought I would try adding two more LED’s via series resistors to ports (P8 & P12).   I modified the pre-written program so that the two additional LED’s would also be controlled.

Stage 2  Breadboard Layout













































BBC micro:bit Edge Connector Breakout Board
Breadboard Connection
P0 pin
Red Traffic LED via 220Ω Resistor
P1 pin
Orange Traffic LED via 220Ω Resistor
P2 pin
Green Traffic LED via 220Ω Resistor
P8 pin
Green Pedestrian LED via 220Ω Resistor
P12 pin
Red Pedestrian LED via 220Ω Resistor
0V Pin
Breadboard negative rail
3V Pin
Breadboard positive rail


Stage 3

The final part of this project was to add a piezo sounder to simulate the crossing beeper.   I connected a piezo sounder to port (P16) via a driver transistor.  I modified the code once more to add this functionality. 

Stage 3 Breadboard Layout











































BBC micro:bit Edge Connector Breakout Board
Breadboard Connection
P0 pin
Red Traffic LED via 220Ω Resistor
P1 pin
Orange Traffic LED via 220Ω Resistor
P2 pin
Green Traffic LED via 220Ω Resistor
P8 pin
Green Pedestrian LED via 220Ω Resistor
P12 pin
Red Pedestrian LED via 220Ω Resistor
P16 pin
2.2k Resistor for Transistor
0V Pin
Breadboard negative rail
3V Pin
Breadboard positive rail

Stage 4

I have added an illuminated external push button which is connected to the button A pin (P5),this lets you trigger or detect a button "A" click externally.   The LED inside the switch is connected to port (P13) via  series resistor.


Stage 4




















BBC micro:bit Edge Connector Breakout Board
Breadboard Connection
P0 pin
Red Traffic LED via 220Ω Resistor
P1 pin
Orange Traffic LED via 220Ω Resistor
P2 pin
Green Traffic LED via 220Ω Resistor
P8 pin
Green Pedestrian LED via 220Ω Resistor
P12 pin
Red Pedestrian LED via 220Ω Resistor
P16 pin
2.2k Resistor for Transistor
P5 pin
Button A – connected to an external  push switch
P13 pin
Pedestrian wait LED via 100Ω Resistor
0V Pin
Breadboard negative rail
3V Pin
Breadboard positive rail


Code

The code has been written in Microsoft Touch Develop and can be found here