[{"data":1,"prerenderedAt":1547},["ShallowReactive",2],{"platform-microbit":3},[4,696,1125],{"id":5,"title":6,"body":7,"description":674,"draft":677,"duration":678,"extension":679,"image":680,"kit":681,"language":685,"level":686,"meta":687,"navigation":688,"path":689,"pdf":690,"platform":691,"seo":692,"stem":693,"youtube":694,"__hash__":695},"tutorials\u002Flearn\u002Fmicrobit\u002Fedublocks\u002Fmicrofit\u002Findex.md","MicroFit - Your very own Step Counter",{"type":8,"value":9,"toc":673},"minimark",[10],[11,12,13,87,93,100,161,192,234,261,307,347,392,442,483,503,547,573],"tutorial-steps",{},[14,15,17,27,39,42],"step",{"title":16},"Overview",[18,19,20,21,26],"p",{},"Ever wondered how a smartwatch or fitness band counts your steps? In this project, you're going to build your very own step counter using a ",[22,23,25],"g",{"slug":24},"micro-bit","micro:bit","!",[18,28,29,30,33,34,38],{},"Inside your micro:bit is a clever little sensor called an ",[22,31,32],{"slug":32},"accelerometer",". It can feel when the micro:bit moves. We'll use it to spot every step you take, add them up, and show the total on the ",[22,35,37],{"slug":36},"led-matrix","LED matrix"," (the grid of lights on the front).",[18,40,41],{},"The best bit? When you're done, you'll have a real working fitness tracker you can pop on and take outside. Don't worry if something doesn't work first time, that's all part of coding. Let's give it a go!",[43,44,47,53],"callout",{"color":45,"icon":46},"green","🎯",[18,48,49],{},[50,51,52],"strong",{},"What you'll learn",[54,55,56,63,66,69,72,79],"ul",{},[57,58,59,60],"li",{},"Make and use your own ",[22,61,62],{"slug":62},"variable",[57,64,65],{},"Use the micro:bit's shake sensor to spot movement",[57,67,68],{},"Show a number on the grid of lights",[57,70,71],{},"Use the buttons to control your project",[57,73,74,75],{},"Use a ",[22,76,78],{"slug":77},"while-loop","while loop",[57,80,81,82,86],{},"Make decisions with ",[22,83,85],{"slug":84},"if-statement","if statement","s",[14,88,90],{"title":89},"What you'll need",[91,92],"what-youll-need",{},[14,94,96],{"title":95},"Key words",[97,98],"key-words",{"terms":99},"variable,while-loop,if-statement,accelerometer,led-matrix,button",[14,101,103,138,145,155],{"title":102},"Set up your micro:bit EduBlocks Editor",[104,105,106,109,120],"ol",{},[57,107,108],{},"Open your web browser. We recommend Google Chrome or Microsoft Edge.",[57,110,111,112,119],{},"In the address bar type ",[113,114,118],"a",{"href":115,"rel":116},"https:\u002F\u002Fapp.edublocks.org\u002F",[117],"nofollow","app.edublocks.org",".",[57,121,122,123,126,127,129,130,133,134,137],{},"Under ",[50,124,125],{},"Create New Project",", select ",[50,128,25],{},". Name your project ",[50,131,132],{},"MicroFit",", and make sure ",[50,135,136],{},"block"," is selected under type.",[18,139,140],{},[141,142],"img",{"alt":143,"src":144},"Creating a new EduBlocks project","\u002Flearn\u002Fmicrobit\u002Fedublocks\u002Fmicrofit\u002FProjectCreation.webp",[104,146,148],{"start":147},4,[57,149,150,151,154],{},"Select ",[50,152,153],{},"Create"," to open the micro:bit editor.",[18,156,157],{},[141,158],{"alt":159,"src":160},"The EduBlocks code area","\u002Flearn\u002Fmicrobit\u002Fedublocks\u002Fmicrofit\u002FCodeArea.webp",[14,162,164,183,186],{"title":163},"Import the MicroPython library",[18,165,150,166,169,170,173,174,178,179,182],{},[50,167,168],{},"Basic",", then ",[50,171,172],{},"Imports",", then snap a ",[175,176,177],"code",{},"from microbit import *"," block onto the ",[175,180,181],{},"#start code here"," block.",[18,184,185],{},"This imports the micro:bit library into EduBlocks so we can use all the micro:bit's functions.",[18,187,188],{},[141,189],{"alt":190,"src":191},"Importing the MicroPython library","\u002Flearn\u002Fmicrobit\u002Fedublocks\u002Fmicrofit\u002FS1_ImportingPythonLibrary.webp",[14,193,195,219,228],{"title":194},"Set steps to 0",[104,196,197,210],{},[57,198,150,199,202,203,206,207,119],{},[50,200,201],{},"Variables",", choose ",[50,204,205],{},"Create a Variable",", and name it ",[50,208,209],{},"steps",[57,211,212,213,216,217,182],{},"Snap a ",[175,214,215],{},"steps = 0"," block to the ",[175,218,177],{},[18,220,221,222,224,225,227],{},"This makes a ",[22,223,62],{"slug":62}," called ",[50,226,209],{}," and starts it at zero.",[18,229,230],{},[141,231],{"alt":232,"src":233},"Setting steps to zero","\u002Flearn\u002Fmicrobit\u002Fedublocks\u002Fmicrofit\u002FS2_SettingStepsToZero.webp",[14,235,237,249,255],{"title":236},"Create a while True loop",[18,238,150,239,169,241,173,244,178,247,182],{},[50,240,168],{},[50,242,243],{},"Loops",[175,245,246],{},"while True:",[175,248,215],{},[18,250,251,252,254],{},"This ",[22,253,78],{"slug":77}," gives us a space to put code that repeats forever.",[18,256,257],{},[141,258],{"alt":259,"src":260},"Creating a while True loop","\u002Flearn\u002Fmicrobit\u002Fedublocks\u002Fmicrofit\u002FS3_CreatingWhileLoop.webp",[14,262,264,296,301],{"title":263},"Detect a shake",[104,265,266,280],{},[57,267,150,268,169,270,273,274,277,278,182],{},[50,269,168],{},[50,271,272],{},"Logic",", then drag an ",[175,275,276],{},"if True:"," block inside the ",[175,279,246],{},[57,281,150,282,285,286,178,289,292,293,119],{},[50,283,284],{},"Accelerometer",", then snap an ",[175,287,288],{},"accelerometer.was_gesture(\"shake\")",[175,290,291],{},"if"," block where it says ",[50,294,295],{},"True",[18,297,251,298,300],{},[22,299,85],{"slug":84}," runs its code only when the micro:bit feels a shake.",[18,302,303],{},[141,304],{"alt":305,"src":306},"Creating the shake function","\u002Flearn\u002Fmicrobit\u002Fedublocks\u002Fmicrofit\u002FS4_CreatingTheShakeFunction.webp",[14,308,310,338,341],{"title":309},"Increase the steps",[104,311,312,321],{},[57,313,150,314,173,316,277,318,182],{},[50,315,201],{},[175,317,215],{},[175,319,320],{},"if accelerometer.was_gesture(\"shake\"):",[57,322,323,324,327,328,331,332,327,335,119],{},"Change the ",[50,325,326],{},"="," to ",[50,329,330],{},"+="," and the ",[50,333,334],{},"0",[50,336,337],{},"1",[18,339,340],{},"Now every detected shake adds one to your step count.",[18,342,343],{},[141,344],{"alt":345,"src":346},"Increasing the steps","\u002Flearn\u002Fmicrobit\u002Fedublocks\u002Fmicrofit\u002FS5_IncreasingStepsBy.webp",[14,348,350,383,386],{"title":349},"Pause the code",[18,351,150,352,169,354,173,357,360,361,364,365,367,368,370,371,373,374,376,377,327,380,119],{},[50,353,168],{},[50,355,356],{},"Statements",[175,358,359],{},"sleep (1000)"," block ",[50,362,363],{},"below"," the ",[175,366,320],{}," block, lined up with the ",[175,369,291],{}," (inside the ",[175,372,246],{}," loop, but not inside the ",[175,375,291],{},"). Change ",[50,378,379],{},"1000",[50,381,382],{},"500",[18,384,385],{},"This pauses for half a second so the loop has time to notice the button press we'll add next.",[18,387,388],{},[141,389],{"alt":390,"src":391},"Pausing the code","\u002Flearn\u002Fmicrobit\u002Fedublocks\u002Fmicrofit\u002FS6_PausingTheCode.webp",[14,393,395,429,436],{"title":394},"Reset the steps with button A",[104,396,397,408,420],{},[57,398,150,399,169,401,285,403,178,405,182],{},[50,400,168],{},[50,402,272],{},[175,404,276],{},[175,406,407],{},"sleep (500)",[57,409,150,410,173,413,178,416,292,418,119],{},[50,411,412],{},"Buttons",[175,414,415],{},"button_a.was_pressed()",[175,417,291],{},[50,419,295],{},[57,421,150,422,173,424,277,426,182],{},[50,423,201],{},[175,425,215],{},[175,427,428],{},"if button_a.was_pressed():",[18,430,431,432,435],{},"Pressing ",[22,433,434],{"slug":434},"button"," A now resets your step count back to zero.",[18,437,438],{},[141,439],{"alt":440,"src":441},"Resetting steps to zero","\u002Flearn\u002Fmicrobit\u002Fedublocks\u002Fmicrofit\u002FS7_ResettingSteps.webp",[14,443,445,471,477],{"title":444},"Show the number of steps",[104,446,447,458],{},[57,448,150,449,173,452,455,456,182],{},[50,450,451],{},"Display",[175,453,454],{},"display.scroll (\"Hello World\")"," block just below the ",[175,457,428],{},[57,459,150,460,173,462,178,464,467,468,119],{},[50,461,201],{},[175,463,209],{},[175,465,466],{},"display.scroll"," block, over the words ",[50,469,470],{},"\"Hello World\"",[18,472,473,474,476],{},"This block sits inside the loop but not inside the button A block, so your steps scroll across the ",[22,475,37],{"slug":36}," all the time, not just when you press A.",[18,478,479],{},[141,480],{"alt":481,"src":482},"Displaying the number of steps","\u002Flearn\u002Fmicrobit\u002Fedublocks\u002Fmicrofit\u002FS8_DisplayingSteps.webp",[14,484,486],{"title":485},"Downloading the Code",[104,487,488,491,497],{},[57,489,490],{},"Connect the micro:bit to the computer with the micro USB cable.",[57,492,150,493,496],{},[50,494,495],{},"Connect"," and follow the on-screen prompts to pair the micro:bit with your web browser.",[57,498,150,499,502],{},[50,500,501],{},"Download"," to send the code to your micro:bit.",[14,504,506,511,514,534,540,544],{"title":505},"Run it and Watch",[507,508,510],"h3",{"id":509},"in-the-web-browser","In the web browser",[18,512,513],{},"EduBlocks has a built-in micro:bit simulator, handy if you haven't got a micro:bit to hand.",[104,515,516,522,528],{},[57,517,518,519,119],{},"On the right-hand side of the screen, select ",[50,520,521],{},"Simulator",[57,523,524,525,119],{},"From the accelerometer menu below the simulator, select ",[50,526,527],{},"Shake",[57,529,150,530,533],{},[50,531,532],{},"Send",". This simulates a shake and shows a number on the simulated micro:bit.",[18,535,536],{},[141,537],{"alt":538,"src":539},"The EduBlocks simulator","\u002Flearn\u002Fmicrobit\u002Fedublocks\u002Fmicrofit\u002FSimulatorPreview.webp",[507,541,543],{"id":542},"on-a-real-microbit","On a real micro:bit",[18,545,546],{},"Once your code's downloaded, give the micro:bit a shake. Each shake bumps your step count up by one on the LED matrix. Pop a battery pack on, attach it to your wrist or ankle, and head outside to watch your steps climb.",[14,548,550],{"title":549},"Try it yourself",[551,552,553],"try-it",{},[18,554,555,558,559,561,562,564,565,568,569,572],{},[50,556,557],{},"Challenge:"," Set yourself a step goal! Add another ",[175,560,291],{}," block inside your ",[175,563,246],{}," loop that checks when ",[175,566,567],{},"steps >= 20",". When you hit it, use a ",[175,570,571],{},"display.show"," block to show a happy face to celebrate, then press button A to reset and go again.",[14,574,576],{"title":575},"Stuck? Quick fixes",[577,578,579,592],"table",{},[580,581,582],"thead",{},[583,584,585,589],"tr",{},[586,587,588],"th",{},"Problem",[586,590,591],{},"Try this",[593,594,595,611,626,645,657,665],"tbody",{},[583,596,597,601],{},[598,599,600],"td",{},"The number doesn't go up when I shake it",[598,602,603,604,607,608,610],{},"Check your ",[175,605,606],{},"steps += 1"," block is inside the ",[175,609,320],{}," block. Give the micro:bit one firm, clear shake.",[583,612,613,616],{},[598,614,615],{},"The count jumps up by lots at once",[598,617,618,619,622,623,625],{},"A big wobble can look like several shakes. Try one single, definite shake, and check the ",[175,620,621],{},"sleep(500)"," block is inside your ",[175,624,246],{}," loop so each shake has time to register.",[583,627,628,631],{},[598,629,630],{},"Nothing shows on the LED matrix",[598,632,633,634,607,636,638,639,641,642,644],{},"Make sure the ",[175,635,209],{},[175,637,466],{}," block (in place of \"Hello World\"), and that ",[175,640,466],{}," is inside your ",[175,643,246],{}," loop.",[583,646,647,650],{},[598,648,649],{},"Button A won't reset the steps",[598,651,652,653,607,655,182],{},"Check the ",[175,654,215],{},[175,656,428],{},[583,658,659,662],{},[598,660,661],{},"The number doesn't update while I keep shaking",[598,663,664],{},"Don't worry, it's still counting! The micro:bit can't show the new number while it's busy scrolling the last one. Stop shaking for a moment and the latest total will scroll across.",[583,666,667,670],{},[598,668,669],{},"My code won't download to the micro:bit",[598,671,672],{},"Use a data USB cable (not a charge-only one), make sure the micro:bit is paired, and try a different USB port.",{"title":674,"searchDepth":675,"depth":675,"links":676},"",2,[],false,"10 mins","md","\u002Flearn\u002Fmicrobit\u002Fedublocks\u002Fmicrofit\u002Fmicrofit-cover.png",[682,25,683,684],"The micro:bit EduBlocks editor","micro USB cable","battery pack for the micro:bit (optional)","edublocks","Beginner",{},true,"\u002Flearn\u002Fmicrobit\u002Fedublocks\u002Fmicrofit","\u002Flearn\u002Fmicrobit\u002Fedublocks\u002Fmicrofit\u002Fmicrofit.pdf","microbit",{"title":6,"description":674},"learn\u002Fmicrobit\u002Fedublocks\u002Fmicrofit\u002Findex",null,"tzU_uk-YKS70h5kDkgwOa0ZIphgODlCg80d72CF0YJo",{"id":697,"title":6,"body":698,"description":674,"draft":677,"duration":678,"extension":679,"image":1115,"kit":1116,"language":1118,"level":686,"meta":1119,"navigation":688,"path":1120,"pdf":1121,"platform":691,"seo":1122,"stem":1123,"youtube":694,"__hash__":1124},"tutorials\u002Flearn\u002Fmicrobit\u002Fpython\u002Fmicrofit\u002Findex.md",{"type":8,"value":699,"toc":1113},[700],[11,701,702,742,746,750,800,827,846,879,897,939,955,988,1014,1036],{},[14,703,704,708,714,716],{"title":16},[18,705,20,706,26],{},[22,707,25],{"slug":24},[18,709,29,710,33,712,38],{},[22,711,32],{"slug":32},[22,713,37],{"slug":36},[18,715,41],{},[43,717,718,722],{"color":45,"icon":46},[18,719,720],{},[50,721,52],{},[54,723,724,728,730,732,734,738],{},[57,725,59,726],{},[22,727,62],{"slug":62},[57,729,65],{},[57,731,68],{},[57,733,71],{},[57,735,74,736],{},[22,737,78],{"slug":77},[57,739,81,740,86],{},[22,741,85],{"slug":84},[14,743,744],{"title":89},[91,745],{},[14,747,748],{"title":95},[97,749],{"terms":99},[14,751,753,778,784,794],{"title":752},"Set up your micro:bit Python Editor",[104,754,755,757,766,771],{},[57,756,108],{},[57,758,111,759,119],{},[50,760,761],{},[113,762,765],{"href":763,"rel":764},"https:\u002F\u002Fpython.microbit.org",[117],"python.microbit.org",[57,767,768,769,119],{},"Give your project a name: select the project name box at the top of the editor and type ",[50,770,132],{},[57,772,773,774,777],{},"Close the left-hand panel by selecting the ",[50,775,776],{},"arrow"," pointing to the left.",[18,779,780],{},[141,781],{"alt":782,"src":783},"Closing the left-hand panel","\u002Flearn\u002Fmicrobit\u002Fpython\u002Fmicrofit\u002FClosingPanel.webp",[104,785,787],{"start":786},5,[57,788,789,790,793],{},"Delete the code on lines ",[50,791,792],{},"5 to 9"," in the main code area.",[18,795,796],{},[141,797],{"alt":798,"src":799},"The Python editor code area","\u002Flearn\u002Fmicrobit\u002Fpython\u002Fmicrofit\u002FCodeArea.webp",[14,801,803,821],{"title":802},"Create a variable",[18,804,805,806,808,809,224,811,813,814,816,817,820],{},"On line 3, type ",[175,807,215],{}," to create a ",[22,810,62],{"slug":62},[50,812,209],{},", set to ",[50,815,334],{}," for when the code starts. Press ",[50,818,819],{},"Enter"," to make a new line.",[18,822,823],{},[141,824],{"alt":825,"src":826},"Creating the steps variable","\u002Flearn\u002Fmicrobit\u002Fpython\u002Fmicrofit\u002FS1_CreatingVariable.webp",[14,828,829,841],{"title":236},[18,830,831,832,834,835,837,838,840],{},"Type ",[175,833,246],{}," and press ",[50,836,819],{},". This creates a ",[22,839,78],{"slug":77},", so anything inside it runs while the condition stays true. Notice your cursor automatically indents, that's how Python shows what's inside the loop.",[18,842,843],{},[141,844],{"alt":259,"src":845},"\u002Flearn\u002Fmicrobit\u002Fpython\u002Fmicrofit\u002FS2_CreatingWhileLoop.webp",[14,847,848,862,873],{"title":263},[104,849,850,858],{},[57,851,831,852,834,855,857],{},[175,853,854],{},"if accelerometer.was_gesture('shake'):",[50,856,819],{},". The cursor indents again.",[57,859,831,860,119],{},[175,861,606],{},[18,863,251,864,866,867,869,870,872],{},[22,865,85],{"slug":84}," adds ",[50,868,337],{}," to your ",[50,871,209],{}," variable every time the micro:bit detects a shake.",[18,874,875],{},[141,876],{"alt":877,"src":878},"Detecting a shake","\u002Flearn\u002Fmicrobit\u002Fpython\u002Fmicrofit\u002FS3_DetectingAShake.webp",[14,880,881,892],{"title":349},[18,882,831,883,885,886,888,889,891],{},[175,884,621],{},". This pauses the code for half a second, giving the micro:bit time to do other things, like check for the button press we'll add next. Press ",[50,887,819],{},", then delete the indent so the cursor lines back up with the ",[175,890,854],{}," line.",[18,893,894],{},[141,895],{"alt":390,"src":896},"\u002Flearn\u002Fmicrobit\u002Fpython\u002Fmicrofit\u002FS4_PausingTheCode.webp",[14,898,899,933],{"title":394},[104,900,901,911,926],{},[57,902,831,903,834,905,907,908,910],{},[175,904,428],{},[50,906,819],{},". This detects a ",[22,909,434],{"slug":434}," press, and the cursor indents.",[57,912,831,913,915,916,918,919,921,922,925],{},[175,914,215],{}," to reset the ",[50,917,209],{}," variable back to ",[50,920,334],{}," when button ",[50,923,924],{},"A"," is pressed.",[57,927,928,929,888,931,891],{},"Press ",[50,930,819],{},[175,932,428],{},[18,934,935],{},[141,936],{"alt":937,"src":938},"Resetting the steps to zero","\u002Flearn\u002Fmicrobit\u002Fpython\u002Fmicrofit\u002FS5_ResettingSteps.webp",[14,940,941,950],{"title":444},[18,942,831,943,946,947,949],{},[175,944,945],{},"display.scroll(steps)",". This scrolls the number of steps across the ",[22,948,37],{"slug":36}," on the front of the micro:bit.",[18,951,952],{},[141,953],{"alt":481,"src":954},"\u002Flearn\u002Fmicrobit\u002Fpython\u002Fmicrofit\u002FS6_DisplayingSteps.webp",[14,956,958,982],{"title":957},"Downloading Your Code",[104,959,960,962,972,977],{},[57,961,490],{},[57,963,964,965,968,969,119],{},"Select the ",[50,966,967],{},"three dots"," next to ",[50,970,971],{},"Send to micro:bit",[57,973,150,974,976],{},[50,975,495],{}," and follow the on-screen prompts.",[57,978,150,979,981],{},[50,980,971],{}," to download the code.",[18,983,984],{},[141,985],{"alt":986,"src":987},"Downloading your code","\u002Flearn\u002Fmicrobit\u002Fpython\u002Fmicrofit\u002FDownloadingCode.webp",[14,989,990,992,1003,1009,1011],{"title":505},[507,991,510],{"id":509},[18,993,994,995,998,999,1002],{},"The Python editor has a built-in micro:bit simulator, handy if you haven't got a micro:bit to hand. Below the simulator you'll see the ",[50,996,997],{},"shake"," function is already selected. Select the ",[50,1000,1001],{},"play"," button next to it to simulate a shake and show your step count on the LED matrix.",[18,1004,1005],{},[141,1006],{"alt":1007,"src":1008},"The Python editor simulator","\u002Flearn\u002Fmicrobit\u002Fpython\u002Fmicrofit\u002FSimulatorDemo.webp",[507,1010,543],{"id":542},[18,1012,1013],{},"Once your code's downloaded, give the micro:bit a shake and watch the step counter climb. Why not go further? Attach a battery pack, strap the micro:bit to you or pop it in your pocket, and head outside to see how many steps you can rack up.",[14,1015,1016],{"title":549},[551,1017,1018],{},[18,1019,1020,558,1022,1024,1025,1027,1028,1031,1032,1035],{},[50,1021,557],{},[175,1023,291],{}," statement inside your ",[175,1026,246],{}," loop that checks ",[175,1029,1030],{},"if steps >= 20:",". When you hit it, type ",[175,1033,1034],{},"display.show(Image.HAPPY)"," to show a happy face and celebrate, then press button A to reset and go again.",[14,1037,1038],{"title":575},[577,1039,1040,1048],{},[580,1041,1042],{},[583,1043,1044,1046],{},[586,1045,588],{},[586,1047,591],{},[593,1049,1050,1062,1073,1088,1096,1107],{},[583,1051,1052,1054],{},[598,1053,600],{},[598,1055,603,1056,1058,1059,1061],{},[175,1057,606],{}," line is indented inside the ",[175,1060,854],{}," statement. Give the micro:bit one firm, clear shake.",[583,1063,1064,1066],{},[598,1065,615],{},[598,1067,618,1068,1070,1071,625],{},[175,1069,621],{}," line is inside your ",[175,1072,246],{},[583,1074,1075,1077],{},[598,1076,630],{},[598,1078,1079,1080,1082,1083,1085,1086,644],{},"Make sure you've typed ",[175,1081,945],{}," with ",[175,1084,209],{}," inside the brackets, and that the line is indented inside your ",[175,1087,246],{},[583,1089,1090,1093],{},[598,1091,1092],{},"The number doesn't change straight away when I shake fast",[598,1094,1095],{},"That's okay, it's still counting! The micro:bit can't show the new number while the last one is still scrolling. Stop shaking for a moment and your latest total will pop up.",[583,1097,1098,1100],{},[598,1099,649],{},[598,1101,652,1102,1058,1104,1106],{},[175,1103,215],{},[175,1105,428],{}," statement.",[583,1108,1109,1111],{},[598,1110,669],{},[598,1112,672],{},{"title":674,"searchDepth":675,"depth":675,"links":1114},[],"\u002Flearn\u002Fmicrobit\u002Fpython\u002Fmicrofit\u002Fmicrofit-cover.png",[1117,25,683,684],"The micro:bit Python editor","python",{},"\u002Flearn\u002Fmicrobit\u002Fpython\u002Fmicrofit","\u002Flearn\u002Fmicrobit\u002Fpython\u002Fmicrofit\u002Fmicrofit.pdf",{"title":6,"description":674},"learn\u002Fmicrobit\u002Fpython\u002Fmicrofit\u002Findex","p_3jg7SGKcFENlFKrxBMxq-YhNgUFCq2Z23TeC2Iv7s",{"id":1126,"title":1127,"body":1128,"description":674,"draft":677,"duration":678,"extension":679,"image":1537,"kit":1538,"language":1540,"level":686,"meta":1541,"navigation":688,"path":1542,"pdf":1543,"platform":691,"seo":1544,"stem":1545,"youtube":694,"__hash__":1546},"tutorials\u002Flearn\u002Fmicrobit\u002Fmakecode\u002Fmicrofit\u002Findex.md","MicroFit: Your very own Step Counter",{"type":8,"value":1129,"toc":1535},[1130],[11,1131,1132,1163,1167,1172,1233,1271,1303,1343,1369,1425,1448,1465],{},[14,1133,1134,1138,1144,1146],{"title":16},[18,1135,20,1136,26],{},[22,1137,25],{"slug":24},[18,1139,29,1140,33,1142,38],{},[22,1141,32],{"slug":32},[22,1143,37],{"slug":36},[18,1145,41],{},[43,1147,1148,1152],{"color":45,"icon":46},[18,1149,1150],{},[50,1151,52],{},[54,1153,1154,1157,1160],{},[57,1155,1156],{},"How a light sensor measures the light around it",[57,1158,1159],{},"How to use an if\u002Felse block to make a decision",[57,1161,1162],{},"How to switch an RGB LED on and off automatically",[14,1164,1165],{"title":89},[91,1166],{},[14,1168,1169],{"title":95},[97,1170],{"terms":1171},"variable,accelerometer,led-matrix,forever-loop,button",[14,1173,1175,1179,1200,1206,1210],{"title":1174},"Navigating to the MakeCode Editor",[507,1176,1178],{"id":1177},"on-a-computer","On a Computer",[104,1180,1181,1184,1192],{},[57,1182,1183],{},"Open your favourite web browser. We recommend either Google Chrome or Microsoft Edge.",[57,1185,1186,1187,119],{},"In the Address bar type ",[113,1188,1191],{"href":1189,"rel":1190},"https:\u002F\u002Fmakecode.microbit.org\u002F#",[117],"makecode.microbit.org",[57,1193,150,1194,1197,1198,119],{},[50,1195,1196],{},"New Project"," and give it the name ",[50,1199,132],{},[18,1201,1202],{},[141,1203],{"alt":1204,"src":1205},"The MakeCode code area","\u002Flearn\u002Fmicrobit\u002Fmakecode\u002Fmicrofit\u002FCodeArea.webp",[507,1207,1209],{"id":1208},"on-a-tablet-or-phone","On a Tablet or Phone",[104,1211,1212,1221,1226],{},[57,1213,1214,1215,1218,1219,119],{},"Open the ",[50,1216,1217],{},"micro:bit app",". If you don't have the app yet you can download it from your devices app store by searching for ",[50,1220,25],{},[57,1222,150,1223,119],{},[50,1224,1225],{},"Create Code",[57,1227,150,1228,1230,1231,119],{},[50,1229,1196],{}," and name it ",[50,1232,132],{},[14,1234,1236,1265],{"title":1235},"Set up the Code Area",[104,1237,1238,1248,1258],{},[57,1239,964,1240,1243,1244,1247],{},[175,1241,1242],{},"on start"," block and drop it on the ",[50,1245,1246],{},"bin"," icon to delete it.",[57,1249,150,1250,1253,1254,1257],{},[50,1251,1252],{},"Input",". Select a ",[175,1255,1256],{},"on shake"," block and drop it within the code area.",[57,1259,150,1260,1253,1262,1257],{},[50,1261,1252],{},[175,1263,1264],{},"on button A pressed",[18,1266,1267],{},[141,1268],{"alt":1269,"src":1270},"Setting up the code area","\u002Flearn\u002Fmicrobit\u002Fmakecode\u002Fmicrofit\u002FS1_SettingUpCodeArea.webp",[14,1272,1274,1292,1297],{"title":1273},"Change Steps by 1",[104,1275,1276,1285],{},[57,1277,150,1278,202,1280,206,1283,119],{},[50,1279,201],{},[50,1281,1282],{},"Make a Variable",[50,1284,209],{},[57,1286,212,1287,277,1290,182],{},[175,1288,1289],{},"change steps by 1",[175,1291,1256],{},[18,1293,1294,1295,119],{},"Every time the micro:bit detects a shake, it adds one to your steps ",[22,1296,62],{"slug":62},[18,1298,1299],{},[141,1300],{"alt":1301,"src":1302},"Adding change steps by 1","\u002Flearn\u002Fmicrobit\u002Fmakecode\u002Fmicrofit\u002FS2_ChangeStepsBy.webp",[14,1304,1305,1328,1337],{"title":444},[104,1306,1307,1317],{},[57,1308,150,1309,173,1311,277,1314,182],{},[50,1310,168],{},[175,1312,1313],{},"show number",[175,1315,1316],{},"forever",[57,1318,150,1319,173,1321,178,1323,1325,1326,119],{},[50,1320,201],{},[175,1322,209],{},[175,1324,1313],{}," block, where it says ",[50,1327,334],{},[18,1329,251,1330,1334,1335],{},[22,1331,1333],{"slug":1332},"forever-loop","forever loop"," keeps running and shows your step count on the ",[22,1336,37],{"slug":36},[18,1338,1339],{},[141,1340],{"alt":1341,"src":1342},"Showing the number of steps","\u002Flearn\u002Fmicrobit\u002Fmakecode\u002Fmicrofit\u002FS3_ShowNumberOfSteps.webp",[14,1344,1346,1355,1364],{"title":1345},"Reset the steps to zero",[18,1347,150,1348,173,1350,277,1353,182],{},[50,1349,201],{},[175,1351,1352],{},"set steps to 0",[175,1354,1264],{},[18,1356,1357,1358,1360,1361,1363],{},"Now, pressing ",[22,1359,434],{"slug":434}," A on the micro:bit resets your step ",[22,1362,62],{"slug":62}," back to zero.",[18,1365,1366],{},[141,1367],{"alt":232,"src":1368},"\u002Flearn\u002Fmicrobit\u002Fmakecode\u002Fmicrofit\u002FS4_SetStepsToZero.webp",[14,1370,1371,1375,1404,1409,1413,1422],{"title":957},[507,1372,1374],{"id":1373},"using-a-computer","Using a Computer",[104,1376,1377,1383,1388,1391,1400],{},[57,1378,964,1379,968,1381,119],{},[50,1380,967],{},[50,1382,501],{},[57,1384,150,1385,119],{},[50,1386,1387],{},"Connect Device",[57,1389,1390],{},"A pop-up will show you how to connect the micro:bit to the computer. Keep following the on-screen instructions.",[57,1392,150,1393,1396,1397,1399],{},[50,1394,1395],{},"BBC micro:bit XXX"," and select ",[50,1398,495],{},". The XXX is your own micro:bit's name, so don't worry if it looks a little different.",[57,1401,150,1402,119],{},[50,1403,501],{},[18,1405,1406],{},[141,1407],{"alt":986,"src":1408},"\u002Flearn\u002Fmicrobit\u002Fmakecode\u002Fmicrofit\u002FDownloadingCode.webp",[507,1410,1412],{"id":1411},"using-a-tablet-or-phone","Using a tablet or phone",[104,1414,1415,1419],{},[57,1416,150,1417,119],{},[50,1418,501],{},[57,1420,1421],{},"Follow the on-screen instructions to pair the micro:bit with the micro:bit app.",[18,1423,1424],{},"Once you've finished the on-screen steps, your code downloads to your micro:bit.",[14,1426,1427,1430,1442],{"title":505},[18,1428,1429],{},"Shake the micro:bit to watch your steps go up. Pop a battery pack on, attach the micro:bit to your wrist or ankle, and head outside to see how many steps you can rack up!",[18,1431,1432,1435,1436,968,1439,1441],{},[50,1433,1434],{},"Dont Have a microbit"," We can test it on the MakeCode editor by selecting the ",[50,1437,1438],{},"white dot",[50,1440,997],{}," on the micro:bit simulator and watch our steps counter climb everytime we select the dot.",[18,1443,1444],{},[141,1445],{"alt":1446,"src":1447},"Shake button on the micro:bit Simulator","\u002Flearn\u002Fmicrobit\u002Fmakecode\u002Fmicrofit\u002FSimDemo.webp",[14,1449,1450],{"title":549},[551,1451,1452],{},[18,1453,1454,1456,1457,277,1459,1461,1462,1464],{},[50,1455,557],{}," Set yourself a step goal! Add an ",[175,1458,291],{},[175,1460,1316],{}," loop to check when ",[175,1463,209],{}," reaches a target, like 20. When you hit it, make the micro:bit show a happy face or play a sound to celebrate, then press button A to reset and go again.",[14,1466,1467],{"title":575},[577,1468,1469,1477],{},[580,1470,1471],{},[583,1472,1473,1475],{},[586,1474,588],{},[586,1476,591],{},[593,1478,1479,1489,1496,1513,1519,1529],{},[583,1480,1481,1483],{},[598,1482,600],{},[598,1484,603,1485,607,1487,610],{},[175,1486,1289],{},[175,1488,1256],{},[583,1490,1491,1493],{},[598,1492,615],{},[598,1494,1495],{},"A big wobble can look like several shakes. Try one single, definite shake each time.",[583,1497,1498,1500],{},[598,1499,630],{},[598,1501,633,1502,1504,1505,1507,1508,1510,1511,182],{},[175,1503,209],{}," variable is snapped inside the ",[175,1506,1313],{}," block, and that ",[175,1509,1313],{}," is inside the ",[175,1512,1316],{},[583,1514,1515,1517],{},[598,1516,1092],{},[598,1518,1095],{},[583,1520,1521,1523],{},[598,1522,649],{},[598,1524,652,1525,607,1527,182],{},[175,1526,1352],{},[175,1528,1264],{},[583,1530,1531,1533],{},[598,1532,669],{},[598,1534,672],{},{"title":674,"searchDepth":675,"depth":675,"links":1536},[],"\u002Flearn\u002Fmicrobit\u002Fmakecode\u002Fmicrofit\u002Fmicrofit-cover.png",[1539,25,683,684],"The micro:bit MakeCode editor","makecode",{},"\u002Flearn\u002Fmicrobit\u002Fmakecode\u002Fmicrofit","\u002Flearn\u002Fmicrobit\u002Fmakecode\u002Fmicrofit\u002Fmicrofit.pdf",{"title":1127,"description":674},"learn\u002Fmicrobit\u002Fmakecode\u002Fmicrofit\u002Findex","4490CD1NuIk6usPyUn6srLDibuRYMQHG40HNn13mwD8",1785347039351]