Moad Asehraoui 1220 AF
It counts how many times the micro:bit has been shaken and if the acceleration is greater than (>) 1000, It stores this number in a variable called ‘steps’, every time the micro:bit accelerometer input senses a shake, the program increases the variable by 1, and shows the new number on the LED display output.
Once the steps reache 10 steps, the varibale called 'Calories' will be increqsed by 40.4 and the distance as well with 0.0006.
To restart the game, you press at A, and to stop the program and display the results, you press at B, it starts and stops after hearing a music from the speaker of the microbit.
The conceptual scheme of the project is as follows:
Description of the application code (firmware):
While true : if accelerometer.get_y() > 1000: steps += 1 counter2 += 1 display.scroll(steps) if counter2 == 10: calories = calories + 40.4 distance += 0.0006 speed = accelerometer.get_y() counter2 = 0
The functions for Button A and B :
if button_a.is_pressed(): music.play(music.POWER_UP) display.scroll("restart") sleep(300) calories = 0 distance = 0 steps = 0 counter = 0 counter2 = 0 time1 = running_time() if button_b.is_pressed(): time2 = running_time() time = (time2 - time1)/1000 music.play(music.POWER_DOWN) display.scroll("Duration:") display.scroll(time) sleep(300) ......
Links of the Video :
Drive : https://drive.google.com/file/d/13ngXFNZwSfSHbOHqf-ctTG2ivulbxQru/view?usp=sharing
Youtube : https://youtu.be/Hnfv7vRd2BI
The Micro Bit (also referred to as BBC Micro Bit, stylized as Micro:bit) is an open source hardware ARM-based embedded system designed by the BBC for use in computer education, that it can be a digital watch,a games console or fitness tracker and stepcounter as i did in my project.
The project can be also improved by adding some functions like the accelerometer so he can measure forces in 3 dimensions, called the X, Y and Z axes. You can modify the code to choose which axis to measure, depending on which way up you fix your micro:bit to your leg or shoe.
The code : code.txt
Github version : https://github.com/MoadAsehraoui/AM-Project.git
Demo video : https://youtu.be/Hnfv7vRd2BI