[{"data":1,"prerenderedAt":525},["ShallowReactive",2],{"microbit-makecode":3},[4],{"id":5,"title":6,"body":7,"description":503,"draft":506,"duration":507,"extension":508,"image":509,"kit":510,"language":514,"level":515,"meta":516,"navigation":517,"path":518,"pdf":519,"platform":520,"seo":521,"stem":522,"youtube":523,"__hash__":524},"tutorials\u002Flearn\u002Fmicrobit\u002Fmakecode\u002Fmicrofit\u002Findex.md","MicroFit: Your very own Step Counter",{"type":8,"value":9,"toc":502},"minimark",[10],[11,12,13,66,72,79,148,188,228,274,302,364,389,410],"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,60,63],"ul",{},[57,58,59],"li",{},"How a light sensor measures the light around it",[57,61,62],{},"How to use an if\u002Felse block to make a decision",[57,64,65],{},"How to switch an RGB LED on and off automatically",[14,67,69],{"title":68},"What you'll need",[70,71],"what-youll-need",{},[14,73,75],{"title":74},"Key words",[76,77],"key-words",{"terms":78},"variable,accelerometer,led-matrix,forever-loop,button",[14,80,82,87,114,121,125],{"title":81},"Navigating to the MakeCode Editor",[83,84,86],"h3",{"id":85},"on-a-computer","On a Computer",[88,89,90,93,104],"ol",{},[57,91,92],{},"Open your favourite web browser. We recommend either Google Chrome or Microsoft Edge.",[57,94,95,96,103],{},"In the Address bar type ",[97,98,102],"a",{"href":99,"rel":100},"https:\u002F\u002Fmakecode.microbit.org\u002F#",[101],"nofollow","makecode.microbit.org",".",[57,105,106,107,110,111,103],{},"Select ",[50,108,109],{},"New Project"," and give it the name ",[50,112,113],{},"MicroFit",[18,115,116],{},[117,118],"img",{"alt":119,"src":120},"The MakeCode code area","\u002Flearn\u002Fmicrobit\u002Fmakecode\u002Fmicrofit\u002FCodeArea.webp",[83,122,124],{"id":123},"on-a-tablet-or-phone","On a Tablet or Phone",[88,126,127,136,141],{},[57,128,129,130,133,134,103],{},"Open the ",[50,131,132],{},"micro:bit app",". If you don't have the app yet you can download it from your devices app store by searching for ",[50,135,25],{},[57,137,106,138,103],{},[50,139,140],{},"Create Code",[57,142,106,143,145,146,103],{},[50,144,109],{}," and name it ",[50,147,113],{},[14,149,151,182],{"title":150},"Set up the Code Area",[88,152,153,165,175],{},[57,154,155,156,160,161,164],{},"Select the ",[157,158,159],"code",{},"on start"," block and drop it on the ",[50,162,163],{},"bin"," icon to delete it.",[57,166,106,167,170,171,174],{},[50,168,169],{},"Input",". Select a ",[157,172,173],{},"on shake"," block and drop it within the code area.",[57,176,106,177,170,179,174],{},[50,178,169],{},[157,180,181],{},"on button A pressed",[18,183,184],{},[117,185],{"alt":186,"src":187},"Setting up the code area","\u002Flearn\u002Fmicrobit\u002Fmakecode\u002Fmicrofit\u002FS1_SettingUpCodeArea.webp",[14,189,191,216,222],{"title":190},"Change Steps by 1",[88,192,193,206],{},[57,194,106,195,198,199,202,203,103],{},[50,196,197],{},"Variables",", choose ",[50,200,201],{},"Make a Variable",", and name it ",[50,204,205],{},"steps",[57,207,208,209,212,213,215],{},"Snap a ",[157,210,211],{},"change steps by 1"," block inside the ",[157,214,173],{}," block.",[18,217,218,219,103],{},"Every time the micro:bit detects a shake, it adds one to your steps ",[22,220,221],{"slug":221},"variable",[18,223,224],{},[117,225],{"alt":226,"src":227},"Adding change steps by 1","\u002Flearn\u002Fmicrobit\u002Fmakecode\u002Fmicrofit\u002FS2_ChangeStepsBy.webp",[14,229,231,258,268],{"title":230},"Show the number of steps",[88,232,233,245],{},[57,234,106,235,238,239,212,242,215],{},[50,236,237],{},"Basic",", then snap a ",[157,240,241],{},"show number",[157,243,244],{},"forever",[57,246,106,247,238,249,251,252,254,255,103],{},[50,248,197],{},[157,250,205],{}," block onto the ",[157,253,241],{}," block, where it says ",[50,256,257],{},"0",[18,259,260,261,265,266],{},"This ",[22,262,264],{"slug":263},"forever-loop","forever loop"," keeps running and shows your step count on the ",[22,267,37],{"slug":36},[18,269,270],{},[117,271],{"alt":272,"src":273},"Showing the number of steps","\u002Flearn\u002Fmicrobit\u002Fmakecode\u002Fmicrofit\u002FS3_ShowNumberOfSteps.webp",[14,275,277,286,296],{"title":276},"Reset the steps to zero",[18,278,106,279,238,281,212,284,215],{},[50,280,197],{},[157,282,283],{},"set steps to 0",[157,285,181],{},[18,287,288,289,292,293,295],{},"Now, pressing ",[22,290,291],{"slug":291},"button"," A on the micro:bit resets your step ",[22,294,221],{"slug":221}," back to zero.",[18,297,298],{},[117,299],{"alt":300,"src":301},"Setting steps to zero","\u002Flearn\u002Fmicrobit\u002Fmakecode\u002Fmicrofit\u002FS4_SetStepsToZero.webp",[14,303,305,309,342,348,352,361],{"title":304},"Downloading Your Code",[83,306,308],{"id":307},"using-a-computer","Using a Computer",[88,310,311,320,325,328,338],{},[57,312,155,313,316,317,103],{},[50,314,315],{},"three dots"," next to ",[50,318,319],{},"Download",[57,321,106,322,103],{},[50,323,324],{},"Connect Device",[57,326,327],{},"A pop-up will show you how to connect the micro:bit to the computer. Keep following the on-screen instructions.",[57,329,106,330,333,334,337],{},[50,331,332],{},"BBC micro:bit XXX"," and select ",[50,335,336],{},"Connect",". The XXX is your own micro:bit's name, so don't worry if it looks a little different.",[57,339,106,340,103],{},[50,341,319],{},[18,343,344],{},[117,345],{"alt":346,"src":347},"Downloading your code","\u002Flearn\u002Fmicrobit\u002Fmakecode\u002Fmicrofit\u002FDownloadingCode.webp",[83,349,351],{"id":350},"using-a-tablet-or-phone","Using a tablet or phone",[88,353,354,358],{},[57,355,106,356,103],{},[50,357,319],{},[57,359,360],{},"Follow the on-screen instructions to pair the micro:bit with the micro:bit app.",[18,362,363],{},"Once you've finished the on-screen steps, your code downloads to your micro:bit.",[14,365,367,370,383],{"title":366},"Run it and Watch",[18,368,369],{},"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,371,372,375,376,316,379,382],{},[50,373,374],{},"Dont Have a microbit"," We can test it on the MakeCode editor by selecting the ",[50,377,378],{},"white dot",[50,380,381],{},"shake"," on the micro:bit simulator and watch our steps counter climb everytime we select the dot.",[18,384,385],{},[117,386],{"alt":387,"src":388},"Shake button on the micro:bit Simulator","\u002Flearn\u002Fmicrobit\u002Fmakecode\u002Fmicrofit\u002FSimDemo.webp",[14,390,392],{"title":391},"Try it yourself",[393,394,395],"try-it",{},[18,396,397,400,401,212,404,406,407,409],{},[50,398,399],{},"Challenge:"," Set yourself a step goal! Add an ",[157,402,403],{},"if",[157,405,244],{}," loop to check when ",[157,408,205],{}," 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,411,413],{"title":412},"Stuck? Quick fixes",[414,415,416,429],"table",{},[417,418,419],"thead",{},[420,421,422,426],"tr",{},[423,424,425],"th",{},"Problem",[423,427,428],{},"Try this",[430,431,432,447,455,474,482,494],"tbody",{},[420,433,434,438],{},[435,436,437],"td",{},"The number doesn't go up when I shake it",[435,439,440,441,443,444,446],{},"Check your ",[157,442,211],{}," block is inside the ",[157,445,173],{}," block. Give the micro:bit one firm, clear shake.",[420,448,449,452],{},[435,450,451],{},"The count jumps up by lots at once",[435,453,454],{},"A big wobble can look like several shakes. Try one single, definite shake each time.",[420,456,457,460],{},[435,458,459],{},"Nothing shows on the LED matrix",[435,461,462,463,465,466,468,469,471,472,215],{},"Make sure the ",[157,464,205],{}," variable is snapped inside the ",[157,467,241],{}," block, and that ",[157,470,241],{}," is inside the ",[157,473,244],{},[420,475,476,479],{},[435,477,478],{},"The number doesn't change straight away when I shake fast",[435,480,481],{},"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.",[420,483,484,487],{},[435,485,486],{},"Button A won't reset the steps",[435,488,489,490,443,492,215],{},"Check the ",[157,491,283],{},[157,493,181],{},[420,495,496,499],{},[435,497,498],{},"My code won't download to the micro:bit",[435,500,501],{},"Use a data USB cable (not a charge-only one), make sure the micro:bit is paired, and try a different USB port.",{"title":503,"searchDepth":504,"depth":504,"links":505},"",2,[],false,"10 mins","md","\u002Flearn\u002Fmicrobit\u002Fmakecode\u002Fmicrofit\u002Fmicrofit-cover.png",[511,25,512,513],"The micro:bit MakeCode editor","micro USB cable","battery pack for the micro:bit (optional)","makecode","Beginner",{},true,"\u002Flearn\u002Fmicrobit\u002Fmakecode\u002Fmicrofit","\u002Flearn\u002Fmicrobit\u002Fmakecode\u002Fmicrofit\u002Fmicrofit.pdf","microbit",{"title":6,"description":503},"learn\u002Fmicrobit\u002Fmakecode\u002Fmicrofit\u002Findex",null,"4490CD1NuIk6usPyUn6srLDibuRYMQHG40HNn13mwD8",1785347039696]