Blinkers for a Bike or a Scooter
by Ville148 in Circuits > Microcontrollers
260 Views, 2 Favorites, 0 Comments
Blinkers for a Bike or a Scooter
My scooter had no blinkers and I had to make a school project with micro:bit so I decided to try coding them myself. The case is only temporary because I didn't feel like leaving my scooter to school for a few weeks for assessing.
Supplies
-microbit
-batteries
-micro-USB (to transfer the code to micro:bit)
-2 (yellow) LEDs
-2 push buttons
-wire and jumper wire
-crocodile clips (for testing the code, not used in the final product)
-breakout board for micro:bit
-breadboard (for testing the circuit)
-soldering iron and solder
-heat-sink tube
-laser cutter
The Coding
Both of the LEDs are in the same forever block but in different "IF" blocks. At first I coded only one LED to Pin 1 and the switch for it in Pin 0.
LED 1 turns-on when Pin 0 is pressed, stays on for 0,75 seconds and turns off for 0,5 seconds. This is in a repeat loop which makes the LED 1 blink 10 times. You can change the duration of the led turning-on and off how you like and how many times the code repeats before turning of the LED 1.
Next I copied the code for the LED 2 which is coded into Pin 15. The switch is coded into Pin 2. You can test the code in the MakeCode editor by clicking the corresponding Pins (Pin 0 and Pin 2). The Pins 1 and 15 should be blinking depending on what pin you pressed.
Now I had both LEDs working but the problem was if I wanted to turn the other way right after, both of the LEDs would be blinking. I solved this by adding an "IF" block inside the repeat loops. If the Pin 2 is pressed during the Pin 0 loop micro:bit resets itself and vice versa. This means that also the LEDs turn off. For some reason the reset part of the code works different in the code editor and in the test circuit. In the code editor you have to hold the other pin to reset and press again to activate the LED. In the test circuit holding reset turns off the other led and turns-on the other one right away. There is no need to press the push button again.
Downloads
The Test Circuit
Because we are using Pins 1 and 15 for the LEDs, there is no need for resistors. Ignore the fact that pin 15 and ground are in the wrong places in my drawing.
Connect pin 1 to LED 1 anode (+) and pin 15 to LED 2 anode (+).
From LED 1 cathode (-) to LED 2 cathode (-) and from LED 2 cathode (-) to ground.
Connect pin 0 to push button 1 and pin 2 to push button 2. These push buttons didn't have - and + so it doesn't matter which way you connect them.
Connect push button 1 free leg to push button 2 free leg and from push button 2 to ground.
The circuit should now be working if you remembered to but batteries into your micro:bit or it is connected to a computer. Press push button 1 to make LED 1 blink. If you want to make LED 2 blink before LED 1 stops blinking, hold the push button 2 for a moment and vice versa.
Soldering and Making a Case
I used jumper wires to connect from micro:bit. From the other end I removed the plastic clip and soldered it straight to a LED or a wire. I secured the connections with heat-shrink tubes to prevent short circuits.
For the case I used makercase.com. Take measurements and plan where you want your switches and your LEDs. I didn't concentrate on this too much because I was thinking to put this directly on my scooter a bit later.
Make It Better
I tried to use more powerful LEDs but they needed more power than micro:bit's pins output. I tried using an outside power source and a transistor but did not manage to get them working. I have to experiment this more.
Using This Project in Teaching
Practice coding with micro:bit and how to make test circuits using a breadboard. Students can work in pairs.
What is needed: micro:bits, usb cables, crocodile clips, jumper wires, breadboards, LEDs
Lesson 1 (2x45 min)
Introducing the micro:bit, what it is, how it works and what can be done with it.
The teacher can demonstrate how to make a code for LED to switch on by pressing a button and showing how to make a test circuit for it with crocodile clips. Now students can try themselves in pairs. Fastest can experiment more and try different inputs such as shaking etc.
Lesson 2 (2x45 min)
The teacher can start by asking a few questions about last time. The teacher should also make sure that everyone got their LED to switch on. This time teacher introduces the breadboard and explains how it works. Teacher also goes through how to draw circuits.
First students can draw the circuit they made last time and. After that everyone can try to make the same code and test circuit as last time but using multiple LEDs, jumper wires and a breadboard. Students can also try to use an outside push button to activate LEDs and figure out how to make it blink. Fastest can practice drawing test circuits they have made.
Lesson 3 (2x45 min)
Making traffic lights or blinkers using coding, micro:bit and breadboard. Fast pairs can try them both.
Lesson 4 (2x45 min)
If everyone got their traffic lights or blinkers to work last time students can start planning their own project with micro:bit. Those who did not get their test circuit to work can try again and and start planning their own project after they have made it work. The project is to make a code and a working test circuit for it they can share at last lesson.
Lessons 5,6.7... consider how many is needed.
Students can experiment, test and improve their own project.
Final lesson
Pairs can introduce their projects to each other and find out what others have made.
Making a self-assessment and giving feedback to others.