START A BIT > Blog A Bit > This page
We are closing the current Learning Package LP2346: 3 Weeks Recap & Review, 23w46 soon, there will be a small demo and sharing in the coming weekend, our participants are encouraged to build some DIY work for the demo.
Here is the work done by Erxi, "Shake a bit", which is an interesting gaming device.
The hardware used:
Main knowledge points:
Main knowledge used here is variable, if-else conditioning, get the "shaking" sensor input.
The features in demo:
Press button A to start the game, then there are 3 seconds countdown for the player to get ready for crazy shaking
After the countdown, there are 5 seconds timebox, the player should shake the board as much as possible
After the 5 seconds, Micro:bit will display the counting result of how many times the player has shaked
"Shake a bit" by Erxi
"Shake a bit" demo, by Erxi
According to the author and his daddy, the product seemed to be not sensitive enough, even if the player shakes for a specific number of times, of course quickly, the device still counted lower amounts of shaking. In this situation, the implementation was made with "on shake" block.
We had a discussion and analysis together, it should be something similar as the button bouncing issue that we experienced in 23w18 A Side Lesson of Button Bouncy Issue. The "on button ... pressed" should have a pre-processing behind to regulate the event before reporting to callback, so to reduce the "bouncy" issue in a very detail perspective in a very short time, "on shake" block should act similarly, it might have regulated the "shaking" before returning, i.e. it possibly has a threshold to be broken so to say there is a "shaking" event, and it might possibly has a short time buffering to observe that this is really a "shaking" event, but not an interference or noise from the circuit or environment. So, reasonably, the "on shake" block has reduced the "sensitivity".
Then, the author has tried another solution to catch the "shaking" event, using "acceleration ...", even though it's not exactly mapping to a "shaking" event, but this solution now avoids the unnecessary pre-processing for "shaking" sensing, so then the counting of the shaking looks much more sensitive, the produce is more fun to play!
The 1st implementation used "on shake" block
The improved solution used "acceleration ..." directly, the counting of shaking is much more sensitive