5
Train the Trainer Resources Hex Files Here - https://goo.gl/mQoVRV http://microbit.org https://makecode.microbit.org/ In this topic you will explore the range of methods of input that the micro:bit has, and the commands used to code these inputs. Use the reference guide and help feature how each command works. Using Buttons On button pressed command – These Labelled A and B. When pressed they can be used to execute microbit. Task Create a program where each button generates a different image. Pressing both buttons together is a third input event and in this case generates two images that alternate creating a simple animation. When an input is used it can be tested in the simulator. By clicking on that input. Try combining different basic commands to display different information when the buttons are pressed. e.g. an intelligent badge, Showing details like age, name mood etc Debug and Download to the micro:bit. Learning Objectives Understand that the micro:bit takes input, and after processing the input, produces output. Learn the variety of different types of information the micro:bit takes in as input. Apply this knowledge by creating a micro:bit program that takes input and produces an output Computing Concepts Identify and the input devices available on the microbit and their function Use a variety of microbit commands to process the information received as input Use a variety of microbit input event handler commands to create ‘real world’ solutions Topic 3 Need Input and Output Write a list of inputs that a micro:bit has.

Train the Trainer Resources - The Micro:bit Foundation …microbit.org/assets/posts/2018-01-19-train_the_trainer/...Train the Trainer Resources Hex Files Here - In this topic you will

Embed Size (px)

Citation preview

Page 1: Train the Trainer Resources - The Micro:bit Foundation …microbit.org/assets/posts/2018-01-19-train_the_trainer/...Train the Trainer Resources Hex Files Here - In this topic you will

TraintheTrainerResources HexFilesHere-https://goo.gl/mQoVRV

http://microbit.org https://makecode.microbit.org/

Inthistopicyouwillexploretherangeofmethodsofinputthatthemicro:bithas,andthecommandsusedtocodetheseinputs.

Usethereferenceguideandhelpfeaturehoweachcommandworks.

UsingButtons

Onbuttonpressedcommand–TheseLabelledAandB.Whenpressedtheycanbeusedtoexecutemicrobit.

Task

Createaprogramwhereeachbuttongeneratesadifferentimage.Pressingbothbuttonstogetherisathirdinputeventandinthiscasegeneratestwoimagesthatalternatecreatingasimpleanimation.

Whenaninputisuseditcanbetestedinthesimulator.Byclickingonthatinput.

Trycombiningdifferentbasiccommandstodisplaydifferentinformationwhenthebuttonsarepressed.e.g.anintelligentbadge,Showingdetailslikeage,namemoodetc

DebugandDownloadtothemicro:bit.

LearningObjectivesUnderstandthatthemicro:bittakesinput,andafterprocessingtheinput,producesoutput.Learnthevarietyofdifferenttypesofinformationthemicro:bittakesinasinput.Applythisknowledgebycreatingamicro:bitprogramthattakesinputandproducesanoutput

ComputingConceptsIdentifyandtheinputdevicesavailableonthemicrobitandtheirfunctionUseavarietyofmicrobitcommandstoprocesstheinformationreceivedasinputUseavarietyofmicrobitinputeventhandlercommandstocreate‘realworld’solutions

Topic3NeedInputandOutput

Writealistofinputsthatamicro:bithas.

Page 2: Train the Trainer Resources - The Micro:bit Foundation …microbit.org/assets/posts/2018-01-19-train_the_trainer/...Train the Trainer Resources Hex Files Here - In this topic you will

TraintheTrainerResources HexFilesHere-https://goo.gl/mQoVRV

http://microbit.org https://makecode.microbit.org/

UsingOnShakecommand

Theaccelerometeronthemicro:bitwhichdetectschangesinthemicro:bit’smovement.TheOnshakecommandallowstheuseofthisinformation.

Task

Makingasimpledicerequirestheuseofavariable.

TocreateaVariableaccessthistutorial-https://makecode.microbit.org/blocks/variables

Youcodeshouldlooklikethis.

Testinthesimulatortousethesakefeature.Thendownloadtothemicro:bit

UsingOnPincommand-Asinputs,themicrobitPinsareabletodetectchangesincurrent.ThisisspreadbetweenthePinseither0,1,2andPinGND.Themicro:bitisabletodetectthechangeincurrentacrossthePinseventheextremelysmallamountyourbodycauseswhenthepinistouched.InthisexamplewhenPin0istouchedthemicrobitgeneratesanddisplaysarandomnumberbetween0and100.Task

CompletetheLoveMeterProjectTutorial–foundintheprojectsfolder.Thisisatutorial,followtheonscreendirections

Page 3: Train the Trainer Resources - The Micro:bit Foundation …microbit.org/assets/posts/2018-01-19-train_the_trainer/...Train the Trainer Resources Hex Files Here - In this topic you will

TraintheTrainerResources HexFilesHere-https://goo.gl/mQoVRV

http://microbit.org https://makecode.microbit.org/

UsingtheLightlevelcommand.Thelightlevelcommandrequiresanothercommandtodosomethingwithit.e.g.shownumberorassignedtoavariable.

NoticethatwhenyouusetheLightlevelcommandthesimulatorasmallhalffilledcircleappears,byclickanddraggingtheborderbetweenthelightanddark,youcanvarytheamountofvirtuallight.thevaluenexttoitwilldisplayonthemicrobit.0equalsdarkand254equalsfulllightByassigningthelightlevelcommandtostoreitsvalueinavariableyoucangetmorecontrolofwhenandwherethereadingsaretaken.

TaskUsingthebuttonandavariableitispossibletomakeasimplelightmeterrecorder

UsingtheTemperaturecommand-ThisworksinasimilarwaytotheLightcommand.Itiseasierandmoreproductivetoassignthetemperaturevaluetoavariable.

TaskCreateaprogramthatautomaticallyconvertsthetemperaturereadingtofromcentigradetoFahrenheit.

Whereinyourschoolcurriculumcouldthesefeaturesbeusedandextended?

Page 4: Train the Trainer Resources - The Micro:bit Foundation …microbit.org/assets/posts/2018-01-19-train_the_trainer/...Train the Trainer Resources Hex Files Here - In this topic you will

TraintheTrainerResources HexFilesHere-https://goo.gl/mQoVRV

http://microbit.org https://makecode.microbit.org/

Usingthemagnetometertocreateacompass.Likeananaloguecompassthesensordetecttheearth’smagneticfielditreturnavaluethatiscompassheading.Tomakesurethesensorworks

well.Itisadvisabletoaddacalibrationfunctiontothecode.ThiscanbedonebyassigningthecalibratecompassfunctiontoapressofbothA+B.

Againavariablehasbeenusedtoassignthecompassheadingandagainthemicrobitsimulatorwillshowavirtualheadingdialwhichcanbeusedtotestyourcode.TaskBuildamoreusefulcompassthatconvertstheheadingvalueintoadirection.Detailsforbuildingthiscompasscanbehere–https://makecode.microbit.org/lessons/compass

UsingtheaccelerationcommandThereisanaccelerometeronthemicro:bitwhichdetectschangesinthemicro:bit’smovement.It convertsanalogueinformationintoadigitalformthatcanbeusedinmicro:bitprograms.Outputisinmilli-g.Thedevicewillalsodetectasmallnumberofstandardactionse.g.shake,tiltandfree-fall.TaskExplorethereferencedocumentationherehttps://makecode.microbit.org/reference/input/accelerationUsethesebuttonstoseethecodeinactionFindoutwhattheydo.

Createthiscodeanddownloadittoamicro:bit.Carefully‘swing’themicro:bit.Whathappens?

Page 5: Train the Trainer Resources - The Micro:bit Foundation …microbit.org/assets/posts/2018-01-19-train_the_trainer/...Train the Trainer Resources Hex Files Here - In this topic you will

TraintheTrainerResources HexFilesHere-https://goo.gl/mQoVRV

http://microbit.org https://makecode.microbit.org/

TrainerReflection

MakerActivitieshttps://make.techwillsaveus.com/bbc-microbit/activities/electro-fishinghttps://make.techwillsaveus.com/bbc-microbit/activities/shooting-hoopshttp://microbitgadgets.co.uk/microbit-projects/microbit-games/bbc-microbit-steady-hand-gameTablefootball-https://youtu.be/zqnDAzaKnvA

SmileyButton-https://makecode.microbit.org/projects/smiley-buttonsLovemeter-https://makecode.microbit.org/lessons/love-meter/activitySimpleThermometer-https://makecode.microbit.org/reference/input/temperature Compass-https://makecode.microbit.org/lessons/compass GlowingPedulum-https://makecode.microbit.org/lessons/glowing-pendulum

Topic3NeedInputandOutput

Whathaveyoulearntinthistopic?

Whatelsedoyouthinkyouneedtoknowaboutthistopicandhowwillyoufindthisout?

Howmightyouintroducethistopictootherteachers?

Whatareasofthistopicmightbedifficulttoteachorunderstandforotherteachers?