Difference between revisions of "Microbit"

From PrattWiki
Jump to navigation Jump to search
(Created page with "This is most definitely a sandbox page for the micro:bit! == Links == Links first? What? * [https://microbit.org/ micro:bit educational foundation] == Installation == * [ht...")
 
 
Line 17: Line 17:
 
* <code>display.show(Image.IMG)</code>
 
* <code>display.show(Image.IMG)</code>
 
** Displays [https://microbit-micropython.readthedocs.io/en/latest/tutorials/images.html built-in images]
 
** Displays [https://microbit-micropython.readthedocs.io/en/latest/tutorials/images.html built-in images]
 +
* <code>sleep(MSEC)</code>
 +
** Pauses for the specified number of microseconds
  
 
== Samples ==
 
== Samples ==

Latest revision as of 17:31, 2 June 2022

This is most definitely a sandbox page for the micro:bit!

Links

Links first? What?

Installation

Python

  • Can run from web page, but needs Chrome versus other browsers.

Commands

  • from microbit import *
    • Imports all commands (note: may want to use prefixes at some point!)
  • display.scroll(STR)
    • Scrolls text across 5x5 LCD array
  • display.show(Image.IMG)
  • sleep(MSEC)
    • Pauses for the specified number of microseconds

Samples

Hour hand rotation

from microbit import *

while True:
    for k in range(12):
        cmd = "display.show(Image.CLOCK{:0.0f})".format(k+1)
        print(cmd)
        exec(cmd)
        sleep(200)