This file contains 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 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 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 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 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 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 time, board, digitalio | |
print("CircuitPython on PyCharm is Awesome!") | |
led = digitalio.DigitalInOut(board.LED) | |
led.direction = digitalio.Direction.OUTPUT | |
while True: | |
led.value = True | |
time.sleep(0.5) |
This file contains 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]) |
This file contains 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
// countriesAndFlags is a dictionary of country names : flag emojis | |
// countries is a String array of country names in alphabetical order | |
struct Constants { | |
static let countriesAndFlags = ["Afghanistan": "🇦🇫", | |
"Åland Islands": "🇦🇽", | |
"Albania": "🇦🇱", | |
"Algeria": "🇩🇿", | |
"American Samoa": "🇦🇸", |
This file contains 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 With Color Picker - Adafruit I0 | |
import board, time, neopixel | |
import os, ssl, socketpool, wifi | |
import adafruit_minimqtt.adafruit_minimqtt as MQTT | |
# import lines for audio & mp3 playing | |
from audiopwmio import PWMAudioOut as AudioOut | |
from audiomp3 import MP3Decoder | |
# setup the speaker | |
audio = AudioOut(board.GP16) # assuming tip of speaker attached to GP16 |
This file contains 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
# mount_sd.py | |
import board, busio, sdcardio, storage | |
# setup pins for SPI | |
sck = board.GP10 # yellow | |
si = board.GP11 # blue | |
so = board.GP12 # green | |
cs = board.GP13 # yellow | |
spi = busio.SPI(sck, si, so) | |
sdcard = sdcardio.SDCard(spi, cs) |
NewerOlder