Updates for ItsyBitsy M4

This commit is contained in:
Kattni Rembor 2018-07-03 19:11:54 -04:00
parent 11ad657f63
commit 247abbe6e6
12 changed files with 24 additions and 45 deletions

View file

@ -1,13 +1,10 @@
# CircuitPython demo - Dotstar
import time
import adafruit_dotstar
import board
num_pixels = 30
pixels = adafruit_dotstar.DotStar(
board.A1, board.A2, num_pixels, brightness=0.1, auto_write=False)
pixels = adafruit_dotstar.DotStar(board.A1, board.A2, num_pixels, brightness=0.1, auto_write=False)
def wheel(pos):

View file

@ -1,7 +1,7 @@
import time
import board
# For Trinket M0, Gemma M0, and ItsyBitsy M0 Express
# 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

View file

@ -1,7 +1,7 @@
import time
import board
# For Trinket M0, Gemma M0, and ItsyBitsy M0 Express
# 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

View file

@ -1,15 +1,12 @@
# CircuitPython demo - NeoPixel
import time
import board
import neopixel
pixel_pin = board.A1
num_pixels = 8
pixels = neopixel.NeoPixel(pixel_pin, num_pixels,
brightness=0.3, auto_write=False)
pixels = neopixel.NeoPixel(pixel_pin, num_pixels, brightness=0.3, auto_write=False)
def wheel(pos):

View file

@ -1,15 +1,13 @@
# CircuitPython demo - NeoPixel RGBW
import time
import board
import neopixel
pixel_pin = board.A1
num_pixels = 8
pixels = neopixel.NeoPixel(pixel_pin, num_pixels,
brightness=0.3, auto_write=False,
pixels = neopixel.NeoPixel(pixel_pin, num_pixels, brightness=0.3, auto_write=False,
pixel_order=(1, 0, 2, 3))

View file

@ -1,5 +1,4 @@
import time
import board
import pulseio

View file

@ -1,15 +1,12 @@
import time
import board
import pulseio
# For the M0 boards:
piezo = pulseio.PWMOut(board.A2, duty_cycle=0,
frequency=440, variable_frequency=True)
# For Metro M4 Express:
# piezo = pulseio.PWMOut(
# board.A1, duty_cycle=0, frequency=440, variable_frequency=True
# )
piezo = pulseio.PWMOut(board.A2, duty_cycle=0, frequency=440, variable_frequency=True)
# For the M4 boards:
# piezo = pulseio.PWMOut(board.A1, duty_cycle=0, frequency=440, variable_frequency=True)
while True:
for f in (262, 294, 330, 349, 392, 440, 494, 523):

View file

@ -1,5 +1,4 @@
import time
import board
import simpleio
@ -7,7 +6,7 @@ while True:
for f in (262, 294, 330, 349, 392, 440, 494, 523):
# For the M0 boards:
simpleio.tone(board.A2, f, 0.25) # on for 1/4 second
# For the Metro M4 Express:
# For the M4 boards:
# simpleio.tone(board.A1, f, 0.25) # on for 1/4 second
time.sleep(0.05) # pause between notes
time.sleep(0.5)

View file

@ -1,11 +1,10 @@
import time
import board
import simpleio
# For the M0 boards:
servo = simpleio.Servo(board.A2)
# For Metro M4 Express:
# For the M4 boards:
# servo = simpleio.Servo(board.A1)
while True:

View file

@ -1,6 +1,6 @@
import board
import busio
from microcontroller import Pin
def is_hardware_I2C(scl, sda):
try:
@ -14,16 +14,10 @@ def is_hardware_I2C(scl, sda):
def get_unique_pins():
pin_names = dir(board)
if "NEOPIXEL" in pin_names:
pin_names.remove("NEOPIXEL")
if "APA102_MOSI" in pin_names:
pin_names.remove("APA102_MOSI")
if "APA102_SCK" in pin_names:
pin_names.remove("APA102_SCK")
if "D13" in pin_names:
pin_names.remove("D13")
pins = [getattr(board, p) for p in pin_names]
exclude = ['NEOPIXEL', 'APA102_MOSI', 'APA102_SCK']
pins = [pin for pin in [
getattr(board, p) for p in dir(board) if p not in exclude]
if isinstance(pin, Pin)]
unique = []
for p in pins:
if p not in unique:

View file

@ -6,8 +6,10 @@ for pin_name in dir(board):
try:
p = pulseio.PWMOut(pin)
p.deinit()
print("PWM on:", pin_name) # Prints the valid, PWM-capable pins!
print("PWM on:", pin_name)
except ValueError: # This is the error returned when the pin is invalid.
print("No PWM on:", pin_name) # Prints the invalid pins.
except RuntimeError: # Timer conflict error.
print("Timers in use:", pin_name) # Prints the timer conflict pins.
except TypeError: # Error returned when checking a non-pin object in dir(board).
pass # Passes over non-pin objects in dir(board).

View file

@ -1,5 +1,6 @@
import board
import busio
from microcontroller import Pin
def is_hardware_uart(tx, rx):
@ -12,14 +13,10 @@ def is_hardware_uart(tx, rx):
def get_unique_pins():
pin_names = dir(board)
if "NEOPIXEL" in pin_names:
pin_names.remove("NEOPIXEL")
if "APA102_MOSI" in pin_names:
pin_names.remove("APA102_MOSI")
if "APA102_SCK" in pin_names:
pin_names.remove("APA102_SCK")
pins = [getattr(board, p) for p in pin_names]
exclude = ['NEOPIXEL', 'APA102_MOSI', 'APA102_SCK']
pins = [pin for pin in [
getattr(board, p) for p in dir(board) if p not in exclude]
if isinstance(pin, Pin)]
unique = []
for p in pins:
if p not in unique: