fbpx
Micropython Lesson 1: Getting Started
Micropython Lesson 1

Micropython Setup

Setting up the environment for Micropython

What is Micropython?

MicroPython is a lean and efficient implementation of the Python 3 programming language that includes a small subset of the Python standard library and is optimized to run on microcontrollers and in constrained environments. Learn more about MicroPython

It is very useful to use an IDE to program your Magicbit with MicroPython firmware. Thonny IDE will be introduced to you in this session. Using MicroPython and the Thonny IDE, you’ll have your first LED blinking using Micropython and thonny IDE.

Upload Micropython firmware using Magicbit Uploader

If you are starting the programing, you should have uploaded the micropython firmware to the magicbit.

  1. Use the magicbit web uploader or download and install Magicbit uploader offline
  2. Connect Magicbit to the computer
  3. In the web uploader, press connect button and select the correct COM port. If you are using magicbit uploader offline, open Magicbit Uploader and select your device COM Port & press connect.

 

4. Install Micropython firmware

 

Programming your Magicbit using Pythonlive

To program your Magicbit using Micropython, you will need a MicroPython IDE (Integrated Development Environment).  You can use the online MircoPython Live IDE provided by us at https://magicbit.cc/pythonlive 

 

Programming your Magicbit using Thonny IDE

Another way to program your Magicbit using MicroPython is to install Thonny IDE. Follow the steps below to install Thonny IDE.

 

Installing Thonny IDE

  1. Go to https://thonny.org
  2. Download the version for Windows and wait a few seconds while it downloads.Download Thonny IDE
  3. Run the .exe file.Install Thonny
  4. Follow the installation wizard to complete the installation process. You just need to click “Next”.
  5. After completing the installation, open Thonny IDE. A window as shown in the following figure should open.

Create First Project (LED Blink)

  • Open Thonny IDE
  • Copy – Paste following code on the editor
from machine import Pin
import time
led = Pin(16, Pin.OUT)
for i in range(10):
     led.on()
     time.sleep_ms(500)
     led.off()
     time.sleep_ms(500)



  • click save as and select ‘Micropython Device’ and choose file name as ‘boot.py’

 

  • Click Run (Green Arrow) on the IDE — If the Green LED on the backside of the Magicbit is blinking, you have just begun the magic with Magicbit

Related Posts
Leave a Reply