STEAM DISCOVERY LAB
  • About
  • Tools
  • Projects
  • Resources
  • About
  • Tools
  • Projects
  • Resources
Search

MicroPython/micro:bit helpful tips and sample codes

Here are some sample codes and helpful tips to help you get up and running with MicroPython, micro:bit, and Grove Shield. 
Blinking light from button
Picture
Plug in an LED into port 0 of the Grove Shield. This code will make the LED blink when the A button is pressed.
Code Editor

    
Radio
Picture
​If you push the A button on one Micro:Bit the other will react. 
 

    
Play-doh
Picture
Using Play-Doh to complete a circuit causes a reaction on the screen of the Micro:Bit
 

    
Reading sensors
Picture
Plug in an analog sensor to port 0 of the Grove Shield and the value of the sensor (ranging from 0 to 1023) will flash on the screen. ​
 

    
Controlling screen brightness
Picture
Press the A button to make the screen brighter and the B button to dim the screen.
Code Editor

    
Random numbers
Picture
Every 400ms a new random number between 1 and 10 is displayed on the screen.
Code Editor

    
Speech
Attach a speaker to the Grove Shield. The Micro:bit will 'say' something if one of the buttons is pressed. ​​
 

    
Morse code
Picture
SOURCE: https://microbit-micropython.readthedocs.io/en/latest/tutorials/network.html?highlight=morse%20code
Tap out letters on the A button and press the B button to read your message. ​

    
Motors
Picture
Changing the position of the sensor (in port 1) will cause the motor (in port 0) to change speed.
Code Editor

    
Picture
200 Boston Ave, Medford, MA 02155
steamdiscoverylab@gmail.com
Center for Engineering Education and Outreach
​Tufts University
About
Tools
Projects
Resources
​
Contact
LEGO®, the LEGO® logo, the Brick, MINDSTORMS®, and the Minifigure are trademarks of ©The LEGO® Group. On some parts of this site  you will get access to so-called “developer software”, which offers documentation on different ways to operate the LEGO® Education SPIKE™ Prime Hub and technology. Whatever use you make of the developer software, bear in mind that the results are not experiences that the LEGO Group endorses, is with or will be liable for. No rights in or to trademarks of the LEGO Group are implied or given, and you may not apply to or register any protection anywhere in the world for intellectual property or industrial rights or similar in respect of any developer software, derivative or other result achieved through its use. The developer software is made available “as is” and, to the extent possible, no warranties or representations are implied or given in relation to it by the LEGO Group. It’s your responsibility to ensure all uses that you make and enable others to make comply with all applicable laws and best practices. By accessing the developer software, you acknowledge that the terms and conditions set out above and in LEGO Education’s terms of use for SPIKE Prime apply.
  • About
  • Tools
  • Projects
  • Resources