This repo features examples for MicroPython similar to Arduino.
Sample boot file which points to 'helloWorld.py' to run after booting. The examples in this repo will not include copies of the boot file. Please edit and include boot.py accordingly.
Turns on LED 4 (the blue LED).
REPL stands for Read-Eval-Print-Loop.
Very important and highly useful feature that allows easy debugging and quick learning.
All examples can be tested on the board without having to manually upload every time.
Replicates Arduino's Blink sketch exactly (uses .on() and .off() and loops)
Replicates Arduino's BlinkWithoutDelay sketch (uses .toggle() and .millis())
Same as Blink, but uses .toggle()
Similar to Arduino's Fade sketch
Something more interesting that simple blinks
Similar to previous 'Heartbeat' script, but fades the light in and out instead of just switching on and off
Pull down button that toggles an LED
Simple analog input that controls an LED's intensity
Simple demo of the Switch object that can control the inbuilt USR button on the pyboard
Example of the Switch.callback function (uses interrupts)
Example of using on of the pins to control an output (LED, motor, buzzer, relay, et al)
Controls blink speed of an LED using the accelerometer's value along the X axis
This script also features a custom remap() function that remaps a value to different bounds/range
Prints the x,y,z values of the accelerometer every second (REPL required)
Example of setting a servo's angle, and animating it over time
Generates a random number roughly between -90 and 90, and sets it as the servo's angle. The servo's angle is then obtained from the object
Uses the RTC (independent Real Time Clock) in the pyboard. Prints the time and date with delay of 100 microseconds. Start time is set with variables.
Sets the device as a HID when it boots.
main.py Control cursor with the pyboard's accelerometer. The USR switch is used as the button. Hold the board such that side with the microUSB port points to the direction you face.