Lesson 2: Programming the Mirco:Bit in Python
To Know - Using Python in Microbit Classroom.
To Be Able To - Develop Basic Programs in Python
Watch the videeo to answer the question below:
What are some of the issues they are facing?
How can they be addressed?
Dice Rolling Program
Brainstorm with your partners.
What are the four main things we need a dice rolling program to do?
Hint: Picture how you use a dice - you throw it, wait for it to land on a number, read the number and repeat.
The Most Important Line
Whenever coding the micro:bit this line must be included as it allows python to use the micro:bit's built in functions.
Introduction of a loop repeats the code, in this instance allowing lines of code sequenced inside it to repeat.
This line monitors for motion with the micro:bit's built in accelerometer, actioning code inside it when a positive signal is detected.
To generate a random number you must import the random capability for the python code.
Once generated the random number must be saved into a variable so it can be called upon when required.
The display line calls upon the saved variable as the value the mirco:bit needs to express on the LED display.
Your Turn
Try coding yourself, following the tutorials in the project tab