4 Digit Clock [Micro:bit]
This is how you build a Working 4-digit analog clock via Micro:bit, using very simple materials.
Disclaimer: It will not be able to sync with the actual time on your computer.
You will have set it up when you boot it up.
You are free to customize this code as you see fit. This is incredibly primitive.
Supplies
- 1 BBC Micro:bit
- 1 Micro:bit Breadboard from the inventors kit.
- 6 Male to female jumper wires for the breadboard.
- 1 Battery to connect to Micro:bit
- 1 MicroUSB to connect to Micro:bit
- 1 Keyestudio 4 digit analog display.
- Technological device, preferably a computer or laptop.
Attach Micro:bit
Begin by attaching the Micro:bit and the Inventor's kit breadboard, allowing you to use the breadboard for other steps.
Begin Wiring
Begin by wiring, since this is the 2nd most annoying part.
All the female sides should be on the left row of the analog pins.
GROUND
Place the FEMALE side wire (Promptly shown as a white wire ) into the 0V Analog pin.
Stick the male side of the white wire onto the J27 Row on the breadboard.
Then connect the male end of the wire ( it is promptly shown as black). TO F27 row on the breadboard.
PIN 1
Place the FEMALE side (promptly shown as purple) into the 1 Analog pin,
Then stick the male end of the purple wire to the J6 row on the breadboard.
Then get the male end of another wire (promptly shown as yellow) to the F6 row.
PIN 2
Place the FEMALE side (Promptly shown as blue) into the 2 Analog pin.
Then stick the male end of the blue wire into the J9 Row on the breadboard.
Then stick another male end of a wire (Promptly shown as red) into the F9 row on the breadboard.
Finalize Wiring
Finalize the wiring by getting the 4-digit analog clock from Keyestudios
Pin 1
Stick the female side of the PIN 1 wire (Yellow wire) to CLK
Pin 2
Stick the female side of the Pin 2 wire (Red wire) to DIO
Ground
Stick the female side of the pin 2 wire (Black wire) to GND
You have completed wiring!
We will begin coding now.
Give Power/Connect Micro:bit
Attach the micro USB to the microbit itself to give it power and connects the computer to the Microbit
Open Micro:bit.
Get the Correct Extension.
Essentially, this allows you to access code that the 4-digit analog display uses.
So begin by going into Extensions,
You will be taken to a different screen, but don't worry, you can press "Go back" and you'll be able to continue.
Anyways. Search up "4 digit" and you should be able to see TM1637.
That is required for the analog display. So, click it, and it'll begin installing the extension onto your project. Now, we can actually, truly start.
Begin Creating Variables
Begin by making multiple variables, and make at least 7 variables, you can name them whatever you want but for easier reading purposes you have to "appropriately" name them
Most of which should be self explanatory.
Begin Coding
This part of the code is what updates the TM1637 or 4 digit analog display, all it does is check if your using a 12/24 hour mode, and shows the correct time on that display. If the mode gets changed, the micro:bit clears its LED screen.
The only blocks you really need to repeat are exactly in the 2nd image, everything else (excluding the forever loop) is optional and is only for the 12/24 hour mode stuff which is not really needed.
Continue Coding
Continue.
This part of the code just handles button controls. Pressing A+B cycles through different modes and when it reaches the "set time", it resets back to normal.
The only optional code is the section that switches between 12/24, or the 2nd image. You only need those if you want to toggle the time format with the microbit and 4 digit analog display, so if you remove the earlier display code then this stuff can be removed too.
Finalize Coding
The last section is just for time setting controls. When the micro:bit is in "Set time" mode, button A switches between hours and minutes, and button B changes the actual value. If time select is 0, then button B increases the minutes, when its 1, it increases the hour. The minutes loop back to 0 when the time reaches past 59, and if the hours loop back to 0 after the time reaches past 23 (Its shown as 2400 due to the 24HR time format map). All the code does is let you pick what time your changing and updating it when pressing the A button, repeating the blocks like this if you want the time setting feature too.
Upload This Into Your Connected Micro:bit
Press download, and then a little pop-up appears to pair with the Micro:Bit,. Just pair it to that so it can automatically download the. Hex file onto the Micro:bit.
Then, when you are finished, unplug the Micro-USB from the micro:bit and add the battery for power; it should be beside the Micro-USB connector.
You are practically done with it now, cosmetically not the best, but it is now up to you to customize it to anything you see fit.
Thank you for reading this.