Introduction: Tinkercad Micro:bit Calculator
This is my own design on how to use tinkercads micro:bit as a calculator with only the 2 buttons. i Probably could have cleaned up the code but i stayed up to finish this as im not too crazy with coding. If you want to try it out yourself, you can check step 6 on how to use it and use this Link.
Step 1: Startup Pattern
I felt like making a little startup pattern for when you turn is on, so i simply had it activate the lights with a delay. I couldn't get videos but you should be able to see the pattern from top to bottom. For Pretty much this whole project i use 0.1 seconds as the delay time.
Step 2: Ready to Start
This was a pretty small step; i just made a light that will blink when it is waiting for something to be entered.
Step 3: First Number
I have this set up so that the "a" button will subtract an number and the "b" button will add one. Hitting them both will select the number. most of this code here is when you try to go too far, if you hit "a" when at 0 it will flash and same with "b" at 9.
Step 4: Number Selector
Whenever you hit the A and B, it will select the number. This code finds out what you are selecting, and plays a little pattern. This code also chooses if you are selecting the 1st number, the 2nd, or the Equation.
Step 5: The Math
To select the equation and make it a working variable, i assigned each a number. Then i just used a ton of "if" statements.
Step 6: How to Actually Use It
Once you start it, it will go through a pattern and begin blinking to signal you can start. It's a little slow so i would suggest not hitting the buttons too fast. Once it signals to start, you can cycle back and forth from 0-9 using the A and B buttons. once you have your first number, you can hit both of them to select it. It will then play a pattern, and you can repeat to choose a second number. It will then play the pattern and show a couple numbers while loading them, but once they are done you can again use the buttons to choose either +, -, x, /, in that order. Once you hit both of the buttons and select your equation, it will play the pattern and load your calculated number.
Participated in the
Block Code Contest