This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# sasa-chairs | |
# Note: This was demo code set up to show students how the debounced button press doesn't register until | |
# after the song plays. However for some reason I notice when run on a CPB using CircuitPython 9.2.4 | |
# that the song runs a second time, even after the update() has run, the button_B is pressed, and | |
# button_A: False, button_B: False prints <- not expected because my finger remains on button_B. | |
# Here is some sample output. I'm seeing that even after False / False, the sound play restarts & am unsure why. | |
# If I continue holding button_B through one more play, the sound stops, as expected, and button_B.value is True | |
# but I had expected this to occur earlier when I held B through the first complete sound play. | |
# If you'd like to test with my sound, it's in the sasa-chairs folder at: | |
# http://bit.ly/circuitpython-school-files |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import board, digitalio | |
led = digitalio.DigitalInOut(board.LED) | |
led.direction = digitalio.Direction.OUTPUT | |
print("CircuitPython is Awesome!") | |
while True: | |
led.value = True |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# MQTT Raspberry Pi Pico W Robot with Adafruit IO & CircuitPython | |
# Include movement & sounds | |
# YouTube tutorial at https://bit.ly/pico-tutorials | |
# MQTT With Color Picker, Sound & Servo - Adafruit IO | |
import board, time, pwmio, mount_sd | |
import os, ssl, socketpool, wifi | |
import adafruit_minimqtt.adafruit_minimqtt as MQTT | |
from audiopwmio import PWMAudioOut as AudioOut | |
from audiomp3 import MP3Decoder | |
from adafruit_motor import servo |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Pin selections here are based on the original Adafruit Learning System | |
// guide for the Teensy 3.x project. Some of these pin numbers don't even | |
// exist on the smaller SAMD M0 & M4 boards, so you may need to make other | |
// selections: | |
// GRAPHICS SETTINGS (appearance of eye) ----------------------------------- | |
// If using a SINGLE EYE, you might want this next line enabled, which | |
// uses a simpler "football-shaped" eye that's left/right symmetrical. | |
// Default shape includes the caruncle, creating distinct left/right eyes. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# audiomixer-drum-machine.py | |
import board, time, digitalio, touchio | |
import audiomixer, audiocore | |
try: | |
from audioio import AudioOut | |
except ImportError: | |
try: | |
from audiopwmio import PWMAudioOut as AudioOut | |
except ImportError: | |
print("This board does not support audio") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import board, time, digitalio | |
import audiomixer, audiocore | |
from audiopwmio import PWMAudioOut as AudioOut | |
# Speaker setup for the CircuitPlayground boards (not for Pico) | |
speaker = digitalio.DigitalInOut(board.SPEAKER_ENABLE) | |
speaker.direction = digitalio.Direction.OUTPUT | |
speaker.value = True | |
# use speaker location to create an AudioOut object named audio |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# capacitive-touch.py | |
import board, neopixel, time, digitalio, touchio | |
from adafruit_led_animation.color import RED, YELLOW, ORANGE, \ | |
GREEN, TEAL, CYAN, BLUE, PURPLE, MAGENTA, GOLD, PINK, AQUA, \ | |
JADE, AMBER, OLD_LACE, WHITE, BLACK | |
from audiocore import WaveFile | |
try: | |
from audioio import AudioOut | |
except ImportError: | |
try: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Turn on CircuitPlayground's NeoPixels, 1 at a time, | |
# then turn them off one at a time in the opposite direction | |
import time, board, neopixel | |
# Create the object named pixels so we can work with the CPB's lights | |
pixels = neopixel.NeoPixel(board.NEOPIXEL, 10) | |
# Define the colors named BLUE and BLACK | |
BLUE = (0, 0, 255) | |
BLACK = (0, 0, 0) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Code that simply prints a message to the console & flashes the onboard LED every 0.5 seconds | |
import time, board, digitalio | |
print("*** CircuitPython is Awesome! ***") | |
print("*** Look at your board - the LED light should be blinking ***") | |
led = digitalio.DigitalInOut(board.LED) | |
led.direction = digitalio.Direction.OUTPUT | |
while True: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
import SwiftData | |
class PreviewContainer { | |
let container: ModelContainer! // register the container | |
init(_ types: [any PersistentModel.Type], isStoredInMemoryOnly: Bool = true) { | |
let schema = Schema(types) // should be able to pass in any schema & have them registered | |
let config = ModelConfiguration(isStoredInMemoryOnly: isStoredInMemoryOnly) | |
self.container = try! ModelContainer(for: schema, configurations: [config]) |
NewerOlder