Updating Essentials guide to include QT Py.
This commit is contained in:
parent
e32b99320a
commit
3e07b2ff6e
29 changed files with 58 additions and 38 deletions
|
|
@ -1,4 +1,4 @@
|
|||
# CircuitPython AnalogIn Demo
|
||||
"""CircuitPython Essentials Analog In example"""
|
||||
import time
|
||||
import board
|
||||
from analogio import AnalogIn
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
# CircuitPython IO demo - analog output
|
||||
"""CircuitPython Analog Out example"""
|
||||
import board
|
||||
from analogio import AnalogOut
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
"""CircuitPython Essentials Audio Out MP3 Example"""
|
||||
import board
|
||||
import digitalio
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
"""CircuitPython Essentials Audio Out tone example"""
|
||||
import time
|
||||
import array
|
||||
import math
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
"""CircuitPython Essentials Audio Out WAV example"""
|
||||
import time
|
||||
import board
|
||||
import digitalio
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
"""CircuitPython Essentials Capacitive Touch example"""
|
||||
import time
|
||||
|
||||
import board
|
||||
import touchio
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,5 @@
|
|||
# CircuitPython Demo - Cap Touch Multiple Pins
|
||||
# Example does NOT work with Trinket M0!
|
||||
|
||||
"""CircuitPython Essentials Capacitive Touch on two pins example. Does not work on Trinket M0!"""
|
||||
import time
|
||||
|
||||
import board
|
||||
import touchio
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
# Continuous Servo Test Program for CircuitPython
|
||||
"""CircuitPython Essentials Servo continuous rotation servo example"""
|
||||
import time
|
||||
import board
|
||||
import pulseio
|
||||
|
|
|
|||
|
|
@ -1,12 +1,15 @@
|
|||
# CircuitPython IO demo #1 - General Purpose I/O
|
||||
"""CircuitPython Essentials Digital In Out example"""
|
||||
import time
|
||||
import board
|
||||
from digitalio import DigitalInOut, Direction, Pull
|
||||
|
||||
# LED setup.
|
||||
led = DigitalInOut(board.D13)
|
||||
# For QT Py M0. QT Py M0 does not have a D13 LED, so you can connect an external LED instead.
|
||||
# led = DigitalInOut(board.SCK)
|
||||
led.direction = Direction.OUTPUT
|
||||
|
||||
# For Gemma M0, Trinket M0, Metro M0 Express, ItsyBitsy M0 Express, Itsy M4 Express
|
||||
# For Gemma M0, Trinket M0, Metro M0 Express, ItsyBitsy M0 Express, Itsy M4 Express, QT Py M0
|
||||
switch = DigitalInOut(board.D2)
|
||||
# switch = DigitalInOut(board.D5) # For Feather M0 Express, Feather M4 Express
|
||||
# switch = DigitalInOut(board.D7) # For Circuit Playground Express
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
# CircuitPython demo - Dotstar
|
||||
"""CircuitPython Essentials DotStar example"""
|
||||
import time
|
||||
import adafruit_dotstar
|
||||
import board
|
||||
|
|
@ -7,7 +7,7 @@ num_pixels = 30
|
|||
pixels = adafruit_dotstar.DotStar(board.A1, board.A2, num_pixels, brightness=0.1, auto_write=False)
|
||||
|
||||
|
||||
def wheel(pos):
|
||||
def colorwheel(pos):
|
||||
# Input a value 0 to 255 to get a color value.
|
||||
# The colours are a transition r - g - b - back to r.
|
||||
if pos < 0 or pos > 255:
|
||||
|
|
@ -85,7 +85,7 @@ def rainbow_cycle(wait):
|
|||
for j in range(255):
|
||||
for i in range(num_pixels):
|
||||
rc_index = (i * 256 // num_pixels) + j
|
||||
pixels[i] = wheel(rc_index & 255)
|
||||
pixels[i] = colorwheel(rc_index & 255)
|
||||
pixels.show()
|
||||
time.sleep(wait)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
# CircuitPython demo - Keyboard emulator
|
||||
|
||||
"""CircuitPython Essentials HID Keyboard example"""
|
||||
import time
|
||||
|
||||
import board
|
||||
|
|
@ -31,7 +30,10 @@ for pin in keypress_pins:
|
|||
key_pin.pull = digitalio.Pull.UP
|
||||
key_pin_array.append(key_pin)
|
||||
|
||||
# For most CircuitPython boards:
|
||||
led = digitalio.DigitalInOut(board.D13)
|
||||
# For QT Py M0:
|
||||
# led = digitalio.DigitalInOut(board.SCK)
|
||||
led.direction = digitalio.Direction.OUTPUT
|
||||
|
||||
print("Waiting for key pin...")
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
"""CircuitPython Essentials HID Mouse example"""
|
||||
import time
|
||||
|
||||
import analogio
|
||||
import board
|
||||
import digitalio
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
# CircuitPython demo - I2C scan
|
||||
#
|
||||
"""CircuitPython Essentials I2C Scan example"""
|
||||
# If you run this and it seems to hang, try manually unlocking
|
||||
# your I2C bus from the REPL with
|
||||
# >>> import board
|
||||
|
|
|
|||
|
|
@ -1,9 +1,7 @@
|
|||
# CircuitPython Demo - I2C sensor
|
||||
|
||||
"""CircuitPython Essentials I2C sensor example using TSL2591"""
|
||||
import time
|
||||
|
||||
import adafruit_tsl2561
|
||||
import board
|
||||
import adafruit_tsl2591
|
||||
|
||||
i2c = board.I2C()
|
||||
|
||||
|
|
@ -11,16 +9,15 @@ i2c = board.I2C()
|
|||
while not i2c.try_lock():
|
||||
pass
|
||||
# Print the addresses found once
|
||||
print("I2C addresses found:", [hex(device_address)
|
||||
for device_address in i2c.scan()])
|
||||
print("I2C addresses found:", [hex(device_address) for device_address in i2c.scan()])
|
||||
|
||||
# Unlock I2C now that we're done scanning.
|
||||
i2c.unlock()
|
||||
|
||||
# Create library object on our I2C port
|
||||
tsl2561 = adafruit_tsl2561.TSL2561(i2c)
|
||||
tsl2591 = adafruit_tsl2591.TSL2591(i2c)
|
||||
|
||||
# Use the object to print the sensor readings
|
||||
while True:
|
||||
print("Lux:", tsl2561.lux)
|
||||
time.sleep(1.0)
|
||||
print("Lux:", tsl2591.lux)
|
||||
time.sleep(0.5)
|
||||
|
|
@ -1,10 +1,11 @@
|
|||
"""CircuitPython Essentials Internal RGB LED red, green, blue example"""
|
||||
import time
|
||||
import board
|
||||
|
||||
# For Trinket M0, Gemma M0, ItsyBitsy M0 Express, and ItsyBitsy M4 Express
|
||||
import adafruit_dotstar
|
||||
led = adafruit_dotstar.DotStar(board.APA102_SCK, board.APA102_MOSI, 1)
|
||||
# For Feather M0 Express, Metro M0 Express, Metro M4 Express, and Circuit Playground Express
|
||||
# For Feather M0 Express, Metro M0 Express, Metro M4 Express, Circuit Playground Express, QT Py M0
|
||||
# import neopixel
|
||||
# led = neopixel.NeoPixel(board.NEOPIXEL, 1)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,15 +1,16 @@
|
|||
"""CircuitPython Essentials Internal RGB LED rainbow example"""
|
||||
import time
|
||||
import board
|
||||
|
||||
# For Trinket M0, Gemma M0, ItsyBitsy M0 Express and ItsyBitsy M4 Express
|
||||
import adafruit_dotstar
|
||||
led = adafruit_dotstar.DotStar(board.APA102_SCK, board.APA102_MOSI, 1)
|
||||
# For Feather M0 Express, Metro M0 Express, Metro M4 Express and Circuit Playground Express
|
||||
# For Feather M0 Express, Metro M0 Express, Metro M4 Express, Circuit Playground Express, QT Py M0
|
||||
# import neopixel
|
||||
# led = neopixel.NeoPixel(board.NEOPIXEL, 1)
|
||||
|
||||
|
||||
def wheel(pos):
|
||||
def colorwheel(pos):
|
||||
# Input a value 0 to 255 to get a color value.
|
||||
# The colours are a transition r - g - b - back to r.
|
||||
if pos < 0 or pos > 255:
|
||||
|
|
@ -28,5 +29,5 @@ led.brightness = 0.3
|
|||
i = 0
|
||||
while True:
|
||||
i = (i + 1) % 256 # run from 0 to 255
|
||||
led.fill(wheel(i))
|
||||
time.sleep(0.1)
|
||||
led.fill(colorwheel(i))
|
||||
time.sleep(0.01)
|
||||
|
|
|
|||
|
|
@ -1,10 +1,13 @@
|
|||
"""CircuitPython Essentials Storage logging example"""
|
||||
import time
|
||||
|
||||
import board
|
||||
import digitalio
|
||||
import microcontroller
|
||||
|
||||
# For most CircuitPython boards:
|
||||
led = digitalio.DigitalInOut(board.D13)
|
||||
# For QT Py M0:
|
||||
# led = digitalio.DigitalInOut(board.SCK)
|
||||
led.switch_to_output()
|
||||
|
||||
try:
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
"""CircuitPython Essentials Storage logging boot.py file"""
|
||||
import board
|
||||
import digitalio
|
||||
import storage
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
# CircuitPython demo - NeoPixel
|
||||
"""CircuitPython Essentials NeoPixel example"""
|
||||
import time
|
||||
import board
|
||||
import neopixel
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
# CircuitPython demo - NeoPixel RGBW
|
||||
|
||||
"""CircuitPython Essentials NeoPixel RGBW example"""
|
||||
import time
|
||||
import board
|
||||
import neopixel
|
||||
|
|
|
|||
|
|
@ -1,8 +1,12 @@
|
|||
"""CircuitPython Essentials: PWM with Fixed Frequency example."""
|
||||
import time
|
||||
import board
|
||||
import pulseio
|
||||
|
||||
# LED setup for most CircuitPython boards:
|
||||
led = pulseio.PWMOut(board.D13, frequency=5000, duty_cycle=0)
|
||||
# LED setup for QT Py M0:
|
||||
# led = pulseio.PWMOut(board.SCK, frequency=5000, duty_cycle=0)
|
||||
|
||||
while True:
|
||||
for i in range(100):
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
"""CircuitPython Essentials PWM with variable frequency piezo example"""
|
||||
import time
|
||||
import board
|
||||
import pulseio
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
"""CircuitPython Essentials PWM piezo simpleio example"""
|
||||
import time
|
||||
import board
|
||||
import simpleio
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
"""CircuitPython Essentials Servo standard servo example"""
|
||||
import time
|
||||
import board
|
||||
import pulseio
|
||||
|
|
|
|||
|
|
@ -1,10 +1,12 @@
|
|||
# CircuitPython Demo - USB/Serial echo
|
||||
|
||||
"""CircuitPython Essentials UART Serial example"""
|
||||
import board
|
||||
import busio
|
||||
import digitalio
|
||||
|
||||
# For most CircuitPython boards:
|
||||
led = digitalio.DigitalInOut(board.D13)
|
||||
# For QT Py M0:
|
||||
# led = digitalio.DigitalInOut(board.SCK)
|
||||
led.direction = digitalio.Direction.OUTPUT
|
||||
|
||||
uart = busio.UART(board.TX, board.RX, baudrate=9600)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
"""CircuitPython Essentials I2C possible pin-pair identifying script"""
|
||||
import board
|
||||
import busio
|
||||
from microcontroller import Pin
|
||||
|
||||
|
||||
def is_hardware_I2C(scl, sda):
|
||||
try:
|
||||
p = busio.I2C(scl, sda)
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
"""CircuitPython Essentials PWM pin identifying script"""
|
||||
import board
|
||||
import pulseio
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
"""CircuitPython Essentials Hardware SPI pin verification script"""
|
||||
import board
|
||||
import busio
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
"""CircuitPython Essentials UART possible pin-pair identifying script"""
|
||||
import board
|
||||
import busio
|
||||
from microcontroller import Pin
|
||||
|
|
|
|||
Loading…
Reference in a new issue