MicroPython is a lean and fast implementation of the Python 3
programming language that is optimised to run on a microcontroller. It has advantages over traditional programming software such
as C/C++ because it is essentially a live development environment and
your write and debug code much faster…in fact 5-10 times faster than
C++.
It ensures that the memory size/microcontroller performance is optimised and fit for purpose for the application it serves. Many sensor reading and reporting applications do not require a PC based processor as this would make the total application over priced and under-efficient.
As a programming language it is expressive and versatile and allows the developer or enterprise engineering teams to choose components that are optimised both in terms of price and performance.
Micropython is environmentally friendly. Yes, that right and here’s why: when a device boots up using MicroPython it does not consume memory and thus doesn’t incur current drain.
The tutorial, http://micropython.org/doc/tut-contents, is really nice and easy to follow.
To get a micro python prompt to write instructions directly to the board do,
This is what you get from the help() function on micro python interpreter.
To close the screen session do 'Ctrl + a' and 'Ctrl + d' in sequence.
It ensures that the memory size/microcontroller performance is optimised and fit for purpose for the application it serves. Many sensor reading and reporting applications do not require a PC based processor as this would make the total application over priced and under-efficient.
As a programming language it is expressive and versatile and allows the developer or enterprise engineering teams to choose components that are optimised both in terms of price and performance.
Micropython is environmentally friendly. Yes, that right and here’s why: when a device boots up using MicroPython it does not consume memory and thus doesn’t incur current drain.
The tutorial, http://micropython.org/doc/tut-contents, is really nice and easy to follow.
To get a micro python prompt to write instructions directly to the board do,
screen /dev/ttyACM0
This is what you get from the help() function on micro python interpreter.
>>> help()
Welcome to Micro Python!
For online help please visit http://micropython.org/help/.
Quick overview of commands for the board:
pyb.info() -- print some general information
pyb.gc() -- run the garbage collector
pyb.delay(n) -- wait for n milliseconds
pyb.Switch() -- create a switch object
Switch methods: (), callback(f)
pyb.LED(n) -- create an LED object for LED n (n=1,2,3,4)
LED methods: on(), off(), toggle(), intensity()
pyb.Pin(pin) -- get a pin, eg pyb.Pin('X1')
pyb.Pin(pin, m, [p]) -- get a pin and configure it for IO mode m, pull mode p
Pin methods: init(..), value([v]), high(), low()
pyb.ExtInt(pin, m, p, callback) -- create an external interrupt object
pyb.ADC(pin) -- make an analog object from a pin
ADC methods: read(), read_timed(buf, freq)
pyb.DAC(port) -- make a DAC object
DAC methods: triangle(freq), write(n), write_timed(buf, freq)
pyb.RTC() -- make an RTC object; methods: datetime([val])
pyb.rng() -- get a 30-bit hardware random number
pyb.Servo(n) -- create Servo object for servo n (n=1,2,3,4)
Servo methods: calibration(..), angle([x, [t]]), speed([x, [t]])
pyb.Accel() -- create an Accelerometer object
Accelerometer methods: x(), y(), z(), tilt(), filtered_xyz()
Pins are numbered X1-X12, X17-X22, Y1-Y12, or by their MCU name
Pin IO modes are: pyb.Pin.IN, pyb.Pin.OUT_PP, pyb.Pin.OUT_OD
Pin pull modes are: pyb.Pin.PULL_NONE, pyb.Pin.PULL_UP, pyb.Pin.PULL_DOWN
Additional serial bus objects: pyb.I2C(n), pyb.SPI(n), pyb.UART(n)
Control commands:
CTRL-A -- on a blank line, enter raw REPL mode
CTRL-B -- on a blank line, enter normal REPL mode
CTRL-C -- interrupt a running program
CTRL-D -- on a blank line, do a soft reset of the board
For further help on a specific object, type help(obj)
To close the screen session do 'Ctrl + a' and 'Ctrl + d' in sequence.