

Multiple = multiple + 1 # increment the multiple Print("13 times " + str(multiple) + " is " + str(result)) # print the multiplication Result = multiple * 13 # Calculate the result If button_a.was_pressed(): # get the next multiple of the thirteen The REPL is great for test-driving some new commands and performing short experiments - the real power is in scripting though.Ĭreate a new script with File > New and paste in the following code: from microbit import * If you keep executing ay(Sound.HAPPY), the tone will repeat. This code will play a happy tone from the micro:bit's speaker! If you the LED. Next, we can also take control of the on-board speaker by executing the following code: from microbit import * The command will be sent to your micro:bit, which will execute the command and display back the message - nice! We can immediately start executing code in the REPL - Enter this code in the shell tab: print("Hello, World!") The Shell tab should display a block of text that indicates MicroPython is running: Make sure the Files pane and Plotter are visible by selecting them in View > Files, and View > Plotter.Ĭlick the red STOP button to restart the MicroPython on your micro:bit if necessary.
#THONNY EXAMPLE INSTALL#
This will update your micro:bit with the latest version of MicroPython, or install MicroPython if it wasn't already. It's also a good idea to install or update firmware. Open Thonny, and in the menu bar find Run > Select interpreter and choose MicroPython (BBC micro:bit) Let's get set up with scripting in Thonny for the Micro:bit. We'll install Thonny, configure for Micro:bit, and write our first script.Īll you'll need to follow along is a Micro:bit v2 GO kitĭownload Thonny here and run the installer.Ĭonnect your Micro:bit V2 to your computer with the USB cable.

PiicoDev OLED Display Module (128圆4) SSD1306 Price: $13.20ġ0k Slide Potentiometer - (Long Shaft) Price: $6.55ġ6 Mb Serial Flash Memory (16Mb, QSPI, W25Q16JVSSIQ) Price: $2.70
