stage.set_background_color("blue")
sprite = codesters.Sprite("flower4")
sprite.set_size(2)
##########
# this is a global variable,
# we are declaring it outside of a function
score = 0
def changeMyVariable(number):
# but to use it inside of a function, we have to do this
global score
# if we don't use the global keywork, the function things
# we want to use a NEW variable named score
score = number
printMyScore()
stage.wait(2)
def printMyScore():
global score
sprite.say(score)
changeMyVariable(2)
changeMyVariable(7)
changeMyVariable(4)
changeMyVariable(2)
Try the following steps to connect to your Micro:bit:
1. You may need to reload this page and try your program again.
2. Try disconnecting and reconnecting your Micro:bit. Then reload the page and run your program again.
3. If you are still having problems your Micro:bit may have an old
firmware version that is incompatible with Codesters.
To update the firmware follow these instructions from Micro:bit
Are you already running a Codesters project in another tab or window?
Micro:bit can only connect to one web page at a time.
Try stopping other Codesters projects or closing
other tabs or windows that may be using your Micro:bit.
If that doesn't fix the problem try disconnecting your Micro:bit,
reloading this page, and reconnecting your Micro:bit.