Moved pulseio.PWMOut to pwmio.PWMOut
This commit is contained in:
parent
5726364da7
commit
dae70f4c5c
66 changed files with 153 additions and 146 deletions
|
|
@ -19,7 +19,7 @@
|
|||
import time
|
||||
import random
|
||||
import board
|
||||
import pulseio
|
||||
import pwmio
|
||||
from adafruit_motor import servo
|
||||
|
||||
# we are intentionally avoiding Trinket Pin #1 (board.A0)
|
||||
|
|
@ -28,8 +28,8 @@ tilt_servo_pin = board.A2 # servo control line (orange) Trinket Pin #0
|
|||
rotate_servo_pin = board.A1 # servo control line (orange) Trinket Pin #2
|
||||
|
||||
# servo object setup for the M0 boards:
|
||||
tilt_pwm = pulseio.PWMOut(tilt_servo_pin, duty_cycle=2 ** 15, frequency=50)
|
||||
rotate_pwm = pulseio.PWMOut(rotate_servo_pin, duty_cycle=2 ** 15, frequency=50)
|
||||
tilt_pwm = pwmio.PWMOut(tilt_servo_pin, duty_cycle=2 ** 15, frequency=50)
|
||||
rotate_pwm = pwmio.PWMOut(rotate_servo_pin, duty_cycle=2 ** 15, frequency=50)
|
||||
tilt_servo = servo.Servo(tilt_pwm)
|
||||
rotate_servo = servo.Servo(rotate_pwm)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
import time
|
||||
|
||||
import board
|
||||
import pulseio
|
||||
import pwmio
|
||||
from digitalio import DigitalInOut, Direction
|
||||
|
||||
# PWM (fading) LEDs are connected on D0 (PWM not avail on D1)
|
||||
pwm_leds = board.D0
|
||||
pwm = pulseio.PWMOut(pwm_leds, frequency=1000, duty_cycle=0)
|
||||
pwm = pwmio.PWMOut(pwm_leds, frequency=1000, duty_cycle=0)
|
||||
|
||||
# digital LEDs connected on D2
|
||||
digital_leds = DigitalInOut(board.D2)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
"""Simple rainbow swirl example for 3W LED"""
|
||||
import pulseio
|
||||
import pwmio
|
||||
import board
|
||||
import digitalio
|
||||
|
||||
|
|
@ -7,9 +7,9 @@ enable = digitalio.DigitalInOut(board.D10)
|
|||
enable.direction = digitalio.Direction.OUTPUT
|
||||
enable.value = True
|
||||
|
||||
red = pulseio.PWMOut(board.D11, duty_cycle=0, frequency=20000)
|
||||
green = pulseio.PWMOut(board.D12, duty_cycle=0, frequency=20000)
|
||||
blue = pulseio.PWMOut(board.D13, duty_cycle=0, frequency=20000)
|
||||
red = pwmio.PWMOut(board.D11, duty_cycle=0, frequency=20000)
|
||||
green = pwmio.PWMOut(board.D12, duty_cycle=0, frequency=20000)
|
||||
blue = pwmio.PWMOut(board.D13, duty_cycle=0, frequency=20000)
|
||||
|
||||
|
||||
def wheel(pos):
|
||||
|
|
|
|||
|
|
@ -3,10 +3,10 @@
|
|||
import time
|
||||
|
||||
import board
|
||||
import pulseio
|
||||
import pwmio
|
||||
|
||||
# pylint: disable=unused-variable,consider-using-enumerate,redefined-outer-name,too-many-locals
|
||||
piezo = pulseio.PWMOut(board.D0, duty_cycle=0, frequency=440,
|
||||
piezo = pwmio.PWMOut(board.D0, duty_cycle=0, frequency=440,
|
||||
variable_frequency=True)
|
||||
|
||||
# pick the mode here:
|
||||
|
|
|
|||
|
|
@ -14,11 +14,11 @@ All text above must be included in any redistribution.
|
|||
|
||||
import time
|
||||
import board
|
||||
import pulseio
|
||||
import pwmio
|
||||
from adafruit_circuitplayground.express import cpx
|
||||
from adafruit_motor import servo
|
||||
|
||||
pwm = pulseio.PWMOut(board.A1, duty_cycle=2 ** 15, frequency=50)
|
||||
pwm = pwmio.PWMOut(board.A1, duty_cycle=2 ** 15, frequency=50)
|
||||
my_servo = servo.Servo(pwm)
|
||||
|
||||
cpx.pixels.fill((0, 0, 0))
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import time
|
||||
import board
|
||||
import pulseio
|
||||
import pwmio
|
||||
from adafruit_motor import servo
|
||||
from adafruit_bluefruit_connect.packet import Packet
|
||||
from adafruit_bluefruit_connect.button_packet import ButtonPacket
|
||||
|
|
@ -12,7 +12,7 @@ ble = BLERadio()
|
|||
uart = UARTService()
|
||||
advertisement = ProvideServicesAdvertisement(uart)
|
||||
|
||||
pwm = pulseio.PWMOut(board.A3, duty_cycle=2 ** 15, frequency=50)
|
||||
pwm = pwmio.PWMOut(board.A3, duty_cycle=2 ** 15, frequency=50)
|
||||
|
||||
my_servo = servo.Servo(pwm)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,14 +1,14 @@
|
|||
import time
|
||||
|
||||
import board
|
||||
import pulseio
|
||||
import pwmio
|
||||
|
||||
# PWM (fading) LEDs are connected on D0, D2 (PWM not avail on D1)
|
||||
pwm_leds = board.D2
|
||||
pwm = pulseio.PWMOut(pwm_leds, frequency=1000, duty_cycle=0)
|
||||
pwm = pwmio.PWMOut(pwm_leds, frequency=1000, duty_cycle=0)
|
||||
|
||||
pwm2_leds = board.D0
|
||||
pwm2 = pulseio.PWMOut(pwm2_leds, frequency=1000, duty_cycle=0)
|
||||
pwm2 = pwmio.PWMOut(pwm2_leds, frequency=1000, duty_cycle=0)
|
||||
|
||||
brightness = 0 # how bright the LED is
|
||||
fade_amount = 1285 # 2% steping of 2^16
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ from adafruit_clue import clue
|
|||
from adafruit_display_text import label
|
||||
import displayio
|
||||
import terminalio
|
||||
import pulseio
|
||||
import pwmio
|
||||
|
||||
moist_level = 50 # adjust this value as needed for your plant
|
||||
|
||||
|
|
@ -56,7 +56,7 @@ board.DISPLAY.show(clue_display)
|
|||
motor = DigitalInOut(board.P2)
|
||||
motor.direction = Direction.OUTPUT
|
||||
|
||||
buzzer = pulseio.PWMOut(board.SPEAKER, variable_frequency=True)
|
||||
buzzer = pwmio.PWMOut(board.SPEAKER, variable_frequency=True)
|
||||
buzzer.frequency = 1000
|
||||
|
||||
sense_pin = board.P1
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import time
|
|||
import math
|
||||
import board
|
||||
from digitalio import DigitalInOut, Direction, Pull
|
||||
import pulseio
|
||||
import pwmio
|
||||
from adafruit_lsm6ds.lsm6ds33 import LSM6DS33
|
||||
from adafruit_lsm6ds import AccelRange, AccelHPF, Rate
|
||||
from adafruit_display_text import label
|
||||
|
|
@ -50,7 +50,7 @@ sensor.high_pass_filter = AccelHPF.SLOPE
|
|||
sensor.high_pass_filter_enabled = True
|
||||
|
||||
# and make a lil buzzer
|
||||
buzzer = pulseio.PWMOut(board.SPEAKER, variable_frequency=True)
|
||||
buzzer = pwmio.PWMOut(board.SPEAKER, variable_frequency=True)
|
||||
buzzer.frequency = 1000
|
||||
|
||||
max_slope = 0
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ from adafruit_clue import clue
|
|||
from adafruit_display_text import label
|
||||
from adafruit_bitmap_font import bitmap_font
|
||||
import displayio
|
||||
import pulseio
|
||||
import pwmio
|
||||
|
||||
clue.display.brightness = 0.8
|
||||
clue_display = displayio.Group(max_size=4)
|
||||
|
|
@ -74,7 +74,7 @@ def countdown(seconds):
|
|||
timer_label.text = ("Wave to start")
|
||||
|
||||
# setup buzzer
|
||||
buzzer = pulseio.PWMOut(board.SPEAKER, variable_frequency=True)
|
||||
buzzer = pwmio.PWMOut(board.SPEAKER, variable_frequency=True)
|
||||
buzzer.frequency = 1000
|
||||
|
||||
while True:
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ import os
|
|||
import gc
|
||||
|
||||
import board
|
||||
import pulseio
|
||||
import pwmio
|
||||
import analogio
|
||||
import ulab
|
||||
|
||||
|
|
@ -483,7 +483,7 @@ CONV_FACTOR = pin_input.reference_voltage / 65535
|
|||
# Start pwm output on P0 or A1
|
||||
# 400kHz and 55000 (84%) duty_cycle were chosen empirically to maximise
|
||||
# the voltage and the voltage drop detecting a small pair of metal scissors
|
||||
pwm = pulseio.PWMOut(board_pin_output, frequency=400 * 1000,
|
||||
pwm = pwmio.PWMOut(board_pin_output, frequency=400 * 1000,
|
||||
duty_cycle=0, variable_frequency=True)
|
||||
pwm.duty_cycle = 55000
|
||||
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ import busio
|
|||
import adafruit_ds3231
|
||||
import audioio
|
||||
import audiocore
|
||||
import pulseio
|
||||
import pwmio
|
||||
from adafruit_motor import servo
|
||||
import neopixel
|
||||
from adafruit_debouncer import Debouncer
|
||||
|
|
@ -79,7 +79,7 @@ switch_io.pull = digitalio.Pull.UP
|
|||
switch = Debouncer(switch_io)
|
||||
|
||||
# create a PWMOut object on Pin A2.
|
||||
pwm = pulseio.PWMOut(SERVO_PIN, duty_cycle=2 ** 15, frequency=50)
|
||||
pwm = pwmio.PWMOut(SERVO_PIN, duty_cycle=2 ** 15, frequency=50)
|
||||
|
||||
# Create a servo object, my_servo.
|
||||
servo = servo.ContinuousServo(pwm)
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ import busio
|
|||
import adafruit_ds3231
|
||||
import audioio
|
||||
import audiocore
|
||||
import pulseio
|
||||
import pwmio
|
||||
from adafruit_motor import servo
|
||||
import neopixel
|
||||
from adafruit_debouncer import Debouncer
|
||||
|
|
@ -67,7 +67,7 @@ switch_io.pull = digitalio.Pull.UP
|
|||
switch = Debouncer(switch_io)
|
||||
|
||||
# create a PWMOut object on Pin A2.
|
||||
pwm = pulseio.PWMOut(SERVO_PIN, duty_cycle=2 ** 15, frequency=50)
|
||||
pwm = pwmio.PWMOut(SERVO_PIN, duty_cycle=2 ** 15, frequency=50)
|
||||
|
||||
# Create a servo object, my_servo.
|
||||
servo = servo.ContinuousServo(pwm)
|
||||
|
|
|
|||
|
|
@ -2,14 +2,14 @@
|
|||
# Adafruit Industries, 2019. MIT License
|
||||
import time
|
||||
import board
|
||||
import pulseio
|
||||
import pwmio
|
||||
from adafruit_motor import servo
|
||||
import simpleio
|
||||
from adafruit_circuitplayground.express import cpx
|
||||
|
||||
# create a PWMOut object on Pin A2.
|
||||
pwm1 = pulseio.PWMOut(board.A1, duty_cycle=2 ** 15, frequency=50)
|
||||
pwm2 = pulseio.PWMOut(board.A2, duty_cycle=2 ** 15, frequency=50)
|
||||
pwm1 = pwmio.PWMOut(board.A1, duty_cycle=2 ** 15, frequency=50)
|
||||
pwm2 = pwmio.PWMOut(board.A2, duty_cycle=2 ** 15, frequency=50)
|
||||
|
||||
# Create a servo object, my_servo.
|
||||
my_servo1 = servo.Servo(pwm1)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import time
|
||||
import board
|
||||
import pulseio
|
||||
import pwmio
|
||||
|
||||
C4 = 261
|
||||
C_SH_4 = 277
|
||||
|
|
@ -17,7 +17,7 @@ B4 = 493
|
|||
|
||||
def play_note(note):
|
||||
if note[0] != 0:
|
||||
pwm = pulseio.PWMOut(board.D12, duty_cycle = 0, frequency=note[0])
|
||||
pwm = pwmio.PWMOut(board.D12, duty_cycle = 0, frequency=note[0])
|
||||
# Hex 7FFF (binary 0111111111111111) is half of the largest value for a 16-bit int,
|
||||
# i.e. 50%
|
||||
pwm.duty_cycle = 0x7FFF
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import board
|
|||
from adafruit_debouncer import Debouncer
|
||||
import busio as io
|
||||
import digitalio
|
||||
import pulseio
|
||||
import pwmio
|
||||
import adafruit_ssd1306
|
||||
|
||||
i2c = io.I2C(board.SCL, board.SDA)
|
||||
|
|
@ -56,7 +56,7 @@ songbook = {'Twinkle Twinkle': [(C4, 0.5), (C4, 0.5), (G4, 0.5), (G4, 0.5), (A4,
|
|||
|
||||
def play_note(note):
|
||||
if note[0] != 0:
|
||||
pwm = pulseio.PWMOut(board.D12, duty_cycle = 0, frequency=note[0])
|
||||
pwm = pwmio.PWMOut(board.D12, duty_cycle = 0, frequency=note[0])
|
||||
# Hex 7FFF (binary 0111111111111111) is half of the largest value for a 16-bit int,
|
||||
# i.e. 50%
|
||||
pwm.duty_cycle = 0x7FFF
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import time
|
||||
import board
|
||||
import pulseio
|
||||
import pwmio
|
||||
|
||||
C4 = 261
|
||||
C_SH_4 = 277
|
||||
|
|
@ -20,7 +20,7 @@ twinkle = [(C4, 0.5), (C4, 0.5), (G4, 0.5), (G4, 0.5), (A4, 0.5), (A4, 0.5), (G4
|
|||
|
||||
def play_note(note):
|
||||
if note[0] != 0:
|
||||
pwm = pulseio.PWMOut(board.D12, duty_cycle = 0, frequency=note[0])
|
||||
pwm = pwmio.PWMOut(board.D12, duty_cycle = 0, frequency=note[0])
|
||||
# Hex 7FFF (binary 0111111111111111) is half of the largest value for a 16-bit int,
|
||||
# i.e. 50%
|
||||
pwm.duty_cycle = 0x7FFF
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
"""CircuitPython Essentials Servo continuous rotation servo example"""
|
||||
import time
|
||||
import board
|
||||
import pulseio
|
||||
import pwmio
|
||||
from adafruit_motor import servo
|
||||
|
||||
# create a PWMOut object on Pin A2.
|
||||
pwm = pulseio.PWMOut(board.A2, frequency=50)
|
||||
pwm = pwmio.PWMOut(board.A2, frequency=50)
|
||||
|
||||
# Create a servo object, my_servo.
|
||||
my_servo = servo.ContinuousServo(pwm)
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
"""CircuitPython Essentials: PWM with Fixed Frequency example."""
|
||||
import time
|
||||
import board
|
||||
import pulseio
|
||||
import pwmio
|
||||
|
||||
# LED setup for most CircuitPython boards:
|
||||
led = pulseio.PWMOut(board.D13, frequency=5000, duty_cycle=0)
|
||||
led = pwmio.PWMOut(board.D13, frequency=5000, duty_cycle=0)
|
||||
# LED setup for QT Py M0:
|
||||
# led = pulseio.PWMOut(board.SCK, frequency=5000, duty_cycle=0)
|
||||
# led = pwmio.PWMOut(board.SCK, frequency=5000, duty_cycle=0)
|
||||
|
||||
while True:
|
||||
for i in range(100):
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
"""CircuitPython Essentials PWM with variable frequency piezo example"""
|
||||
import time
|
||||
import board
|
||||
import pulseio
|
||||
import pwmio
|
||||
|
||||
# For the M0 boards:
|
||||
piezo = pulseio.PWMOut(board.A2, duty_cycle=0, frequency=440, variable_frequency=True)
|
||||
piezo = pwmio.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)
|
||||
# piezo = pwmio.PWMOut(board.A1, duty_cycle=0, frequency=440, variable_frequency=True)
|
||||
|
||||
while True:
|
||||
for f in (262, 294, 330, 349, 392, 440, 494, 523):
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
"""CircuitPython Essentials Servo standard servo example"""
|
||||
import time
|
||||
import board
|
||||
import pulseio
|
||||
import pwmio
|
||||
from adafruit_motor import servo
|
||||
|
||||
# create a PWMOut object on Pin A2.
|
||||
pwm = pulseio.PWMOut(board.A2, duty_cycle=2 ** 15, frequency=50)
|
||||
pwm = pwmio.PWMOut(board.A2, duty_cycle=2 ** 15, frequency=50)
|
||||
|
||||
# Create a servo object, my_servo.
|
||||
my_servo = servo.Servo(pwm)
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
"""CircuitPython Essentials PWM pin identifying script"""
|
||||
import board
|
||||
import pulseio
|
||||
import pwmio
|
||||
|
||||
for pin_name in dir(board):
|
||||
pin = getattr(board, pin_name)
|
||||
try:
|
||||
p = pulseio.PWMOut(pin)
|
||||
p = pwmio.PWMOut(pin)
|
||||
p.deinit()
|
||||
print("PWM on:", pin_name) # Prints the valid, PWM-capable pins!
|
||||
except ValueError: # This is the error returned when the pin is invalid.
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
import time
|
||||
|
||||
import board
|
||||
import pulseio
|
||||
import pwmio
|
||||
|
||||
led = pulseio.PWMOut(board.D13, frequency=5000, duty_cycle=0)
|
||||
led = pwmio.PWMOut(board.D13, frequency=5000, duty_cycle=0)
|
||||
|
||||
while True:
|
||||
for i in range(100):
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
import time
|
||||
|
||||
import board
|
||||
import pulseio
|
||||
import pwmio
|
||||
|
||||
piezo = pulseio.PWMOut(board.A2, duty_cycle=0,
|
||||
piezo = pwmio.PWMOut(board.A2, duty_cycle=0,
|
||||
frequency=440, variable_frequency=True)
|
||||
|
||||
while True:
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
import board
|
||||
import pulseio
|
||||
import pwmio
|
||||
|
||||
for pin_name in dir(board):
|
||||
pin = getattr(board, pin_name)
|
||||
try:
|
||||
p = pulseio.PWMOut(pin)
|
||||
p = pwmio.PWMOut(pin)
|
||||
p.deinit()
|
||||
print("PWM on:", pin_name) # Prints the valid, PWM-capable pins!
|
||||
except ValueError: # This is the error returned when the pin is invalid.
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import time
|
|||
|
||||
import board
|
||||
import pulseio
|
||||
import pwmio
|
||||
from digitalio import DigitalInOut, Direction, Pull
|
||||
# pylint: disable=eval-used
|
||||
# Switch to select 'stealth-mode'
|
||||
|
|
@ -28,7 +29,7 @@ button_b = DigitalInOut(board.BUTTON_B)
|
|||
button_b.direction = Direction.INPUT
|
||||
button_b.pull = Pull.DOWN
|
||||
|
||||
pwm = pulseio.PWMOut(board.REMOTEOUT, frequency=38000,
|
||||
pwm = pwmio.PWMOut(board.REMOTEOUT, frequency=38000,
|
||||
duty_cycle=2 ** 15, variable_frequency=True)
|
||||
pulse = pulseio.PulseOut(pwm)
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import time
|
|||
import adafruit_dotstar
|
||||
import board
|
||||
import pulseio
|
||||
import pwmio
|
||||
from digitalio import DigitalInOut, Direction
|
||||
|
||||
# pylint: disable=eval-used
|
||||
|
|
@ -17,7 +18,7 @@ pixel.fill((0, 0, 0))
|
|||
led = DigitalInOut(board.D13)
|
||||
led.direction = Direction.OUTPUT
|
||||
|
||||
pwm = pulseio.PWMOut(board.A2, frequency=38000,
|
||||
pwm = pwmio.PWMOut(board.A2, frequency=38000,
|
||||
duty_cycle=2 ** 15, variable_frequency=True)
|
||||
pulse = pulseio.PulseOut(pwm)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
import time
|
||||
import board
|
||||
import pulseio
|
||||
import pwmio
|
||||
|
||||
led = pulseio.PWMOut(board.D5, frequency=5000, duty_cycle=0)
|
||||
led = pwmio.PWMOut(board.D5, frequency=5000, duty_cycle=0)
|
||||
|
||||
while True:
|
||||
for i in range(100):
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
import time
|
||||
import board
|
||||
import pulseio
|
||||
import pwmio
|
||||
from adafruit_motor import servo
|
||||
|
||||
# create a PWMOut object on Pin D5.
|
||||
pwm = pulseio.PWMOut(board.D5, duty_cycle=2 ** 15, frequency=50)
|
||||
pwm = pwmio.PWMOut(board.D5, duty_cycle=2 ** 15, frequency=50)
|
||||
|
||||
# Create a servo object.
|
||||
servo = servo.Servo(pwm)
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
import time
|
||||
import board
|
||||
import pulseio
|
||||
import pwmio
|
||||
|
||||
# Initialize PWM output for the servo (on pin D5):
|
||||
servo = pulseio.PWMOut(board.D5, frequency=50)
|
||||
servo = pwmio.PWMOut(board.D5, frequency=50)
|
||||
|
||||
|
||||
# Create a function to simplify setting PWM duty cycle for the servo:
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import time
|
||||
import board
|
||||
import pwmio
|
||||
import pulseio
|
||||
import adafruit_irremote
|
||||
import neopixel
|
||||
|
|
@ -11,8 +12,8 @@ TRANSMIT_DELAY = 15 # change this as desired to affect game dynamics, or just l
|
|||
# Create NeoPixel object to indicate status
|
||||
pixels = neopixel.NeoPixel(board.NEOPIXEL, 10)
|
||||
|
||||
# Create a 'pulseio' output, to send infrared signals on the IR transmitter @ 38KHz
|
||||
pwm = pulseio.PWMOut(board.IR_TX, frequency=38000, duty_cycle=2 ** 15)
|
||||
# Create a 'pwmio' output, to send infrared signals on the IR transmitter @ 38KHz
|
||||
pwm = pwmio.PWMOut(board.IR_TX, frequency=38000, duty_cycle=2 ** 15)
|
||||
pulseout = pulseio.PulseOut(pwm)
|
||||
|
||||
# Create an encoder that will take numbers and turn them into IR pulses
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import time
|
||||
import pulseio
|
||||
import pwmio
|
||||
import board
|
||||
import adafruit_irremote
|
||||
import digitalio
|
||||
|
|
@ -21,8 +22,8 @@ pulsein = pulseio.PulseIn(board.IR_RX, maxlen=120, idle_state=True)
|
|||
# Create a decoder that will take pulses and turn them into numbers
|
||||
decoder = adafruit_irremote.GenericDecode()
|
||||
|
||||
# Create a 'pulseio' output, to send infrared signals on the IR transmitter @ 38KHz
|
||||
pwm = pulseio.PWMOut(board.IR_TX, frequency=38000, duty_cycle=2 ** 15)
|
||||
# Create a 'pwmio' output, to send infrared signals on the IR transmitter @ 38KHz
|
||||
pwm = pwmio.PWMOut(board.IR_TX, frequency=38000, duty_cycle=2 ** 15)
|
||||
pulseout = pulseio.PulseOut(pwm)
|
||||
# Create an encoder that will take numbers and turn them into NEC IR pulses
|
||||
encoder = adafruit_irremote.GenericTransmit(header=[9500, 4500], one=[550, 550],
|
||||
|
|
|
|||
|
|
@ -3,11 +3,11 @@
|
|||
|
||||
import time
|
||||
import board
|
||||
import pulseio
|
||||
import pwmio
|
||||
from adafruit_motor import servo
|
||||
|
||||
# create a PWMOut object on Pin A1
|
||||
pwm = pulseio.PWMOut(board.A1, frequency=50)
|
||||
pwm = pwmio.PWMOut(board.A1, frequency=50)
|
||||
|
||||
# Create a servo object, my_servo
|
||||
my_servo = servo.Servo(pwm)
|
||||
|
|
|
|||
|
|
@ -2,10 +2,11 @@ import time
|
|||
from adafruit_circuitplayground.express import cpx
|
||||
import adafruit_irremote
|
||||
import pulseio
|
||||
import pwmio
|
||||
import board
|
||||
|
||||
# Create a 'pulseio' output, to send infrared signals on the IR transmitter @ 38KHz
|
||||
pwm = pulseio.PWMOut(board.IR_TX, frequency=38000, duty_cycle=2 ** 15)
|
||||
# Create a 'pwmio' output, to send infrared signals on the IR transmitter @ 38KHz
|
||||
pwm = pwmio.PWMOut(board.IR_TX, frequency=38000, duty_cycle=2 ** 15)
|
||||
pulseout = pulseio.PulseOut(pwm)
|
||||
# Create an encoder that will take numbers and turn them into NEC IR pulses
|
||||
encoder = adafruit_irremote.GenericTransmit(header=[9500, 4500], one=[550, 550],
|
||||
|
|
|
|||
|
|
@ -3,12 +3,12 @@
|
|||
import time
|
||||
import random
|
||||
import board
|
||||
import pulseio
|
||||
import pwmio
|
||||
from adafruit_motor import servo
|
||||
from adafruit_circuitplayground.express import cpx
|
||||
|
||||
# create a PWMOut object on CPX Pin A1
|
||||
pwm = pulseio.PWMOut(board.A1, frequency=50)
|
||||
pwm = pwmio.PWMOut(board.A1, frequency=50)
|
||||
# Create a servo object cpx_servo
|
||||
cpx_servo = servo.Servo(pwm)
|
||||
|
||||
|
|
|
|||
|
|
@ -5,11 +5,11 @@
|
|||
import time
|
||||
|
||||
import board
|
||||
import pulseio
|
||||
import pwmio
|
||||
from adafruit_motor import servo
|
||||
from adafruit_circuitplayground.express import cpx
|
||||
|
||||
pwm = pulseio.PWMOut(board.A3, duty_cycle=2 ** 15, frequency=50)
|
||||
pwm = pwmio.PWMOut(board.A3, duty_cycle=2 ** 15, frequency=50)
|
||||
|
||||
# plug red servo wire to VOUT, brown to GND, yellow to A3
|
||||
servo = servo.Servo(pwm)
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
import time
|
||||
import board
|
||||
import pulseio
|
||||
import pwmio
|
||||
from adafruit_motor import servo
|
||||
from analogio import AnalogIn
|
||||
|
||||
|
|
@ -15,7 +15,7 @@ ANGLE_MIN = 0
|
|||
ANGLE_MAX = 180
|
||||
|
||||
# Setup servo
|
||||
pwm = pulseio.PWMOut(SERVO_PIN, duty_cycle=2 ** 15, frequency=50)
|
||||
pwm = pwmio.PWMOut(SERVO_PIN, duty_cycle=2 ** 15, frequency=50)
|
||||
servo = servo.Servo(pwm)
|
||||
servo.angle = None
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
import time
|
||||
import board
|
||||
import pulseio
|
||||
import pwmio
|
||||
from simpleio import map_range
|
||||
from adafruit_motor import servo
|
||||
from analogio import AnalogIn
|
||||
|
|
@ -40,7 +40,7 @@ led.direction = Direction.OUTPUT
|
|||
led.value = False
|
||||
|
||||
# Setup servo
|
||||
pwm = pulseio.PWMOut(SERVO_PIN, duty_cycle=2 ** 15, frequency=50)
|
||||
pwm = pwmio.PWMOut(SERVO_PIN, duty_cycle=2 ** 15, frequency=50)
|
||||
servo = servo.Servo(pwm)
|
||||
servo.angle = None
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
# Example code for using analog feedback value to seek a position
|
||||
import board
|
||||
import pulseio
|
||||
import pwmio
|
||||
from simpleio import map_range
|
||||
from adafruit_motor import servo
|
||||
from analogio import AnalogIn
|
||||
|
|
@ -19,7 +19,7 @@ ANGLE_MIN = 0
|
|||
ANGLE_MAX = 180
|
||||
|
||||
# Setup servo
|
||||
pwm = pulseio.PWMOut(SERVO_PIN, duty_cycle=2 ** 15, frequency=50)
|
||||
pwm = pwmio.PWMOut(SERVO_PIN, duty_cycle=2 ** 15, frequency=50)
|
||||
servo = servo.Servo(pwm)
|
||||
servo.angle = None
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
# Motion Sensor Alarm
|
||||
# uses Gemma M0, vibration sensor on A0/GND, & piezo on D0/GND
|
||||
import time
|
||||
import pulseio
|
||||
import pwmio
|
||||
from analogio import AnalogIn
|
||||
import board
|
||||
|
||||
piezo = pulseio.PWMOut(board.D0, duty_cycle=0, frequency=440,
|
||||
piezo = pwmio.PWMOut(board.D0, duty_cycle=0, frequency=440,
|
||||
variable_frequency=True)
|
||||
|
||||
vibrationPin = AnalogIn(board.A0)
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import array
|
|||
import math
|
||||
import board
|
||||
import displayio
|
||||
import pulseio
|
||||
import pwmio
|
||||
from adafruit_motor import servo
|
||||
import digitalio
|
||||
import touchio
|
||||
|
|
@ -21,8 +21,8 @@ pir.direction = digitalio.Direction.INPUT
|
|||
led = digitalio.DigitalInOut(LED_PIN)
|
||||
led.direction = digitalio.Direction.OUTPUT
|
||||
# Setup servo
|
||||
# servo = pulseio.PWMOut(board.D4, frequency=50)
|
||||
pwm = pulseio.PWMOut(board.D4)
|
||||
# servo = pwmio.PWMOut(board.D4, frequency=50)
|
||||
pwm = pwmio.PWMOut(board.D4)
|
||||
servo = servo.Servo(pwm)
|
||||
|
||||
# Setup cap touch button
|
||||
|
|
@ -84,7 +84,7 @@ def blink(count, speed):
|
|||
time.sleep(speed)
|
||||
|
||||
# display setup
|
||||
backlight = pulseio.PWMOut(board.TFT_BACKLIGHT)
|
||||
backlight = pwmio.PWMOut(board.TFT_BACKLIGHT)
|
||||
splash = displayio.Group()
|
||||
board.DISPLAY.show(splash)
|
||||
max_brightness = 2 ** 15
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ import time
|
|||
import busio
|
||||
import board
|
||||
import adafruit_lis3dh
|
||||
import pulseio
|
||||
import pwmio
|
||||
from adafruit_motor import servo
|
||||
|
||||
|
||||
|
|
@ -25,8 +25,8 @@ i2c = busio.I2C(board.ACCELEROMETER_SCL, board.ACCELEROMETER_SDA)
|
|||
sensor = adafruit_lis3dh.LIS3DH_I2C(i2c, address=0x19)
|
||||
|
||||
# Setup servos
|
||||
left_pwm = pulseio.PWMOut(board.A1, frequency=50)
|
||||
right_pwm = pulseio.PWMOut(board.A2, frequency=50)
|
||||
left_pwm = pwmio.PWMOut(board.A1, frequency=50)
|
||||
right_pwm = pwmio.PWMOut(board.A2, frequency=50)
|
||||
|
||||
left_ear = servo.Servo(left_pwm)
|
||||
right_ear = servo.Servo(right_pwm)
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
import time
|
||||
|
||||
import board
|
||||
import pulseio
|
||||
import pwmio
|
||||
|
||||
piezo = pulseio.PWMOut(board.D2, duty_cycle=0,
|
||||
piezo = pwmio.PWMOut(board.D2, duty_cycle=0,
|
||||
frequency=440, variable_frequency=True)
|
||||
|
||||
while True:
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import time
|
|||
import busio
|
||||
import board
|
||||
import pulseio
|
||||
import pwmio
|
||||
import adafruit_irremote
|
||||
import adafruit_lis3dh
|
||||
|
||||
|
|
@ -25,8 +26,8 @@ TRANSMIT_DELAY = 0.1
|
|||
i2c = busio.I2C(board.ACCELEROMETER_SCL, board.ACCELEROMETER_SDA)
|
||||
sensor = adafruit_lis3dh.LIS3DH_I2C(i2c, address=0x19)
|
||||
|
||||
# Create a 'pulseio' output, to send infrared signals on the IR transmitter @ 38KHz
|
||||
pwm = pulseio.PWMOut(board.IR_TX, frequency=38000, duty_cycle=2 ** 15)
|
||||
# Create a 'pwmio' output, to send infrared signals on the IR transmitter @ 38KHz
|
||||
pwm = pwmio.PWMOut(board.IR_TX, frequency=38000, duty_cycle=2 ** 15)
|
||||
pulseout = pulseio.PulseOut(pwm)
|
||||
|
||||
# Create an encoder that will take numbers and turn them into IR pulses
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ done.value = False
|
|||
|
||||
#pylint: disable=wrong-import-position,wrong-import-order
|
||||
import time
|
||||
import pulseio
|
||||
import pwmio
|
||||
import busio
|
||||
from adafruit_epd.epd import Adafruit_EPD
|
||||
from adafruit_epd.il0373 import Adafruit_IL0373
|
||||
|
|
@ -31,7 +31,7 @@ sensor = adafruit_si7021.SI7021(i2c)
|
|||
ON = 2**15
|
||||
OFF = 0
|
||||
|
||||
buzzer = pulseio.PWMOut(board.D5, variable_frequency=True)
|
||||
buzzer = pwmio.PWMOut(board.D5, variable_frequency=True)
|
||||
buzzer.duty_cycle = OFF
|
||||
|
||||
silence_button = digitalio.DigitalInOut(board.A5)
|
||||
|
|
|
|||
|
|
@ -2,14 +2,14 @@ import time
|
|||
|
||||
import analogio
|
||||
import board
|
||||
import pulseio
|
||||
import pwmio
|
||||
|
||||
sampleWindow = 0.033 # Sample window width (0.033 sec = 33 mS = ~30 Hz)
|
||||
ledPin = board.D0 # Pin where LEDs are connected (PWM not avail on D1)
|
||||
micPin = board.A1 # Microphone 'OUT' is connected here
|
||||
|
||||
mic = analogio.AnalogIn(micPin)
|
||||
pwm = pulseio.PWMOut(ledPin, frequency=1000, duty_cycle=0)
|
||||
pwm = pwmio.PWMOut(ledPin, frequency=1000, duty_cycle=0)
|
||||
|
||||
while True:
|
||||
# Listen to mic for short interval, recording min & max signal
|
||||
|
|
|
|||
|
|
@ -3,11 +3,11 @@
|
|||
|
||||
import time
|
||||
import board
|
||||
import pulseio
|
||||
import pwmio
|
||||
from adafruit_motor import servo
|
||||
|
||||
# servo pin for the M0 boards:
|
||||
pwm = pulseio.PWMOut(board.A2, duty_cycle=2 ** 15, frequency=50)
|
||||
pwm = pwmio.PWMOut(board.A2, duty_cycle=2 ** 15, frequency=50)
|
||||
my_servo = servo.Servo(pwm)
|
||||
speed = .04 # 40ms lower value means faster movement
|
||||
max_turn = 180 # rotation range 180 degree, half a circle
|
||||
|
|
|
|||
|
|
@ -2,11 +2,11 @@ import time
|
|||
|
||||
import adafruit_motor.servo
|
||||
import board
|
||||
import pulseio
|
||||
import pwmio
|
||||
from analogio import AnalogIn
|
||||
from digitalio import DigitalInOut, Direction, Pull
|
||||
|
||||
pwm = pulseio.PWMOut(board.D5, frequency=50)
|
||||
pwm = pwmio.PWMOut(board.D5, frequency=50)
|
||||
servo = adafruit_motor.servo.Servo(pwm)
|
||||
switch = DigitalInOut(board.D7)
|
||||
switch.direction = Direction.INPUT
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import board
|
|||
import digitalio
|
||||
import time
|
||||
import neopixel
|
||||
import pulseio
|
||||
import pwmio
|
||||
from adafruit_motor import servo
|
||||
from digitalio import DigitalInOut, Direction, Pull
|
||||
|
||||
|
|
@ -69,7 +69,7 @@ SERVO_LIST = [
|
|||
]
|
||||
|
||||
for cur_servo in SERVO_LIST:
|
||||
pwm = pulseio.PWMOut(cur_servo["PIN"], duty_cycle=2 ** 15, frequency=50)
|
||||
pwm = pwmio.PWMOut(cur_servo["PIN"], duty_cycle=2 ** 15, frequency=50)
|
||||
# Create a servo object.
|
||||
cur_servo["SERVO"] = servo.Servo(pwm)
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import board
|
|||
import digitalio
|
||||
import time
|
||||
import neopixel
|
||||
import pulseio
|
||||
import pwmio
|
||||
from adafruit_motor import servo
|
||||
|
||||
pixels = neopixel.NeoPixel(board.NEOPIXEL, 1)
|
||||
|
|
@ -53,7 +53,7 @@ SERVO_LIST = [
|
|||
]
|
||||
|
||||
for cur_servo in SERVO_LIST:
|
||||
pwm = pulseio.PWMOut(cur_servo["PIN"], duty_cycle=2 ** 15, frequency=50)
|
||||
pwm = pwmio.PWMOut(cur_servo["PIN"], duty_cycle=2 ** 15, frequency=50)
|
||||
# Create a servo object.
|
||||
cur_servo["SERVO"] = servo.Servo(pwm)
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ time.sleep().
|
|||
import board
|
||||
import digitalio
|
||||
import time
|
||||
import pulseio
|
||||
import pwmio
|
||||
from adafruit_motor import servo
|
||||
|
||||
SERVO_LIST = [
|
||||
|
|
@ -22,7 +22,7 @@ SERVO_LIST = [
|
|||
]
|
||||
|
||||
for cur_servo in SERVO_LIST:
|
||||
pwm = pulseio.PWMOut(cur_servo["PIN"], duty_cycle=2 ** 15, frequency=50)
|
||||
pwm = pwmio.PWMOut(cur_servo["PIN"], duty_cycle=2 ** 15, frequency=50)
|
||||
# Create a servo object.
|
||||
cur_servo["SERVO"] = servo.Servo(pwm)
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import time
|
|||
import random
|
||||
import board
|
||||
import busio
|
||||
import pulseio
|
||||
import pwmio
|
||||
from digitalio import DigitalInOut, Direction
|
||||
from adafruit_bluefruitspi import BluefruitSPI
|
||||
import adafruit_lis3dh
|
||||
|
|
@ -15,9 +15,9 @@ import adafruit_lis3dh
|
|||
ADVERT_NAME = b'BlinkaNeoLamp'
|
||||
|
||||
# RGB LED on D11, 12, 13, we're using a Prop Maker wing
|
||||
red_led = pulseio.PWMOut(board.D11, frequency=50000, duty_cycle=0)
|
||||
green_led = pulseio.PWMOut(board.D12, frequency=50000, duty_cycle=0)
|
||||
blue_led = pulseio.PWMOut(board.D13, frequency=50000, duty_cycle=0)
|
||||
red_led = pwmio.PWMOut(board.D11, frequency=50000, duty_cycle=0)
|
||||
green_led = pwmio.PWMOut(board.D12, frequency=50000, duty_cycle=0)
|
||||
blue_led = pwmio.PWMOut(board.D13, frequency=50000, duty_cycle=0)
|
||||
# Prop maker wing has a power pin for the LED!
|
||||
power_pin = DigitalInOut(board.D10)
|
||||
power_pin.direction = Direction.OUTPUT
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ import busio
|
|||
import adafruit_ds3231
|
||||
import audioio
|
||||
import audiocore
|
||||
import pulseio
|
||||
import pwmio
|
||||
from adafruit_motor import servo
|
||||
import neopixel
|
||||
from adafruit_debouncer import Debouncer
|
||||
|
|
@ -78,7 +78,7 @@ switch_io.pull = Pull.UP
|
|||
switch = Debouncer(switch_io)
|
||||
|
||||
# create a PWMOut object on Pin A2.
|
||||
pwm = pulseio.PWMOut(SERVO_PIN, duty_cycle=2 ** 15, frequency=50)
|
||||
pwm = pwmio.PWMOut(SERVO_PIN, duty_cycle=2 ** 15, frequency=50)
|
||||
|
||||
# Create a servo object, my_servo.
|
||||
servo = servo.ContinuousServo(pwm)
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import time
|
|||
import board
|
||||
import neopixel
|
||||
import adafruit_irremote
|
||||
import pwmio
|
||||
import pulseio
|
||||
|
||||
pixpin = board.D1
|
||||
|
|
@ -14,7 +15,7 @@ numpix = 60
|
|||
strip = neopixel.NeoPixel(pixpin, numpix, brightness=1, auto_write=False)
|
||||
|
||||
# IR LED output for 38kHz PWM
|
||||
pwm = pulseio.PWMOut(ir_led, frequency=38000)
|
||||
pwm = pwmio.PWMOut(ir_led, frequency=38000)
|
||||
|
||||
# IR Sensor input to detect basketball
|
||||
pulses = pulseio.PulseIn(ir_sensor, maxlen=200, idle_state=True)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import time
|
||||
import board
|
||||
import pulseio
|
||||
import pwmio
|
||||
import simpleio
|
||||
from digitalio import DigitalInOut, Direction, Pull
|
||||
import adafruit_fancyled.adafruit_fancyled as fancy
|
||||
|
|
@ -11,9 +11,9 @@ NEOPIXEL_NUM = 31
|
|||
pixels = neopixel.NeoPixel(NEOPIXEL_PIN, NEOPIXEL_NUM, auto_write=False)
|
||||
|
||||
# Since its common anode, 'off' is max duty cycle
|
||||
red_led = pulseio.PWMOut(board.D9, frequency=5000, duty_cycle=65535)
|
||||
green_led = pulseio.PWMOut(board.D10, frequency=5000, duty_cycle=65535)
|
||||
blue_led = pulseio.PWMOut(board.D11, frequency=5000, duty_cycle=65535)
|
||||
red_led = pwmio.PWMOut(board.D9, frequency=5000, duty_cycle=65535)
|
||||
green_led = pwmio.PWMOut(board.D10, frequency=5000, duty_cycle=65535)
|
||||
blue_led = pwmio.PWMOut(board.D11, frequency=5000, duty_cycle=65535)
|
||||
|
||||
switch = DigitalInOut(board.D12)
|
||||
switch.direction = Direction.INPUT
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ import rotaryio
|
|||
import neopixel
|
||||
from adafruit_debouncer import Debouncer
|
||||
import digitalio
|
||||
import pulseio
|
||||
import pwmio
|
||||
|
||||
# Setup the hardware
|
||||
|
||||
|
|
@ -110,7 +110,7 @@ def beep(count, duration, interstitial, freq):
|
|||
:param float interstitial: the length (in seconds) of the silence between beeps
|
||||
:param int freq: the frequency of the beeps
|
||||
"""
|
||||
pwm = pulseio.PWMOut(board.D12, duty_cycle = 0, frequency=freq)
|
||||
pwm = pwmio.PWMOut(board.D12, duty_cycle = 0, frequency=freq)
|
||||
for _ in range(count):
|
||||
pwm.duty_cycle = 0x7FFF
|
||||
time.sleep(duration)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import time
|
||||
|
||||
import board
|
||||
import pulseio
|
||||
import pwmio
|
||||
|
||||
RED_PIN = board.D5 # Red LED pin
|
||||
GREEN_PIN = board.D6 # Green LED pin
|
||||
|
|
@ -11,9 +11,9 @@ FADE_SLEEP = 10 # Number of milliseconds to delay between changes.
|
|||
# Increase to slow down, decrease to speed up.
|
||||
|
||||
# Define PWM outputs:
|
||||
red = pulseio.PWMOut(RED_PIN)
|
||||
green = pulseio.PWMOut(GREEN_PIN)
|
||||
blue = pulseio.PWMOut(BLUE_PIN)
|
||||
red = pwmio.PWMOut(RED_PIN)
|
||||
green = pwmio.PWMOut(GREEN_PIN)
|
||||
blue = pwmio.PWMOut(BLUE_PIN)
|
||||
|
||||
|
||||
# Function to simplify setting duty cycle to percent value.
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ import board
|
|||
import busio
|
||||
import digitalio
|
||||
import rotaryio
|
||||
import pulseio
|
||||
import pwmio
|
||||
import adafruit_ssd1306
|
||||
from adafruit_motor import servo
|
||||
from adafruit_debouncer import Debouncer
|
||||
|
|
@ -49,7 +49,7 @@ max_pulse_index = 0
|
|||
#-------------------------------------------------------------------------------
|
||||
# Initialize servo
|
||||
|
||||
pwm = pulseio.PWMOut(board.D5, frequency=50)
|
||||
pwm = pwmio.PWMOut(board.D5, frequency=50)
|
||||
test_servo = servo.Servo(pwm, min_pulse=1000, max_pulse=2000)
|
||||
test_servo.angle = 0
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ import math
|
|||
import array
|
||||
import board
|
||||
import audiobusio
|
||||
import pulseio
|
||||
import pwmio
|
||||
from adafruit_motor import servo
|
||||
from adafruit_circuitplayground.express import cpx
|
||||
|
||||
|
|
@ -31,8 +31,8 @@ NUM_SAMPLES = 90
|
|||
|
||||
# the trigger threshhold
|
||||
THRESHOLD = 6
|
||||
left_pwm = pulseio.PWMOut(board.A1, frequency=50)
|
||||
right_pwm = pulseio.PWMOut(board.A2, frequency=50)
|
||||
left_pwm = pwmio.PWMOut(board.A1, frequency=50)
|
||||
right_pwm = pwmio.PWMOut(board.A2, frequency=50)
|
||||
|
||||
left_ear = servo.Servo(left_pwm)
|
||||
right_ear = servo.Servo(right_pwm)
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@ Gemma M0 with Piezo on D0 and GND
|
|||
import time
|
||||
|
||||
import board
|
||||
import pulseio
|
||||
import pwmio
|
||||
|
||||
piezo = pulseio.PWMOut(board.D0, duty_cycle=0, frequency=440,
|
||||
piezo = pwmio.PWMOut(board.D0, duty_cycle=0, frequency=440,
|
||||
variable_frequency=True)
|
||||
|
||||
tempo = 2
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@ Gemma M0 with Piezo on D0 and GND
|
|||
import time
|
||||
|
||||
import board
|
||||
import pulseio
|
||||
import pwmio
|
||||
|
||||
piezo = pulseio.PWMOut(board.D0, duty_cycle=0, frequency=440,
|
||||
piezo = pwmio.PWMOut(board.D0, duty_cycle=0, frequency=440,
|
||||
variable_frequency=True)
|
||||
|
||||
tempo = 1.6
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import time
|
|||
|
||||
import analogio
|
||||
import board
|
||||
import pulseio
|
||||
import pwmio
|
||||
|
||||
try:
|
||||
import urandom as random # for v1.0 API support
|
||||
|
|
@ -23,7 +23,7 @@ photocell = analogio.AnalogIn(photocell_pin)
|
|||
# PWM (fading) - Both LEDs are connected on D0
|
||||
# (PWM not avail on D1)
|
||||
pwm_leds = board.D0
|
||||
pwm = pulseio.PWMOut(pwm_leds, frequency=1000, duty_cycle=0)
|
||||
pwm = pwmio.PWMOut(pwm_leds, frequency=1000, duty_cycle=0)
|
||||
brightness = 0 # how bright the LED is
|
||||
fade_amount = 1285 # 2% steping of 2^16
|
||||
counter = 0 # counter to keep track of cycles
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ import time
|
|||
|
||||
import analogio
|
||||
import board
|
||||
import pulseio
|
||||
import pwmio
|
||||
|
||||
photocell_pin = board.A1 # CdS photocell connected to this ANALOG pin
|
||||
speaker_pin = board.D0 # Speaker is connected to this DIGITAL pin
|
||||
|
|
@ -19,7 +19,7 @@ scale = 0.03 # Change this to adjust tone scale
|
|||
|
||||
# Initialize input/output pins
|
||||
photocell = analogio.AnalogIn(photocell_pin)
|
||||
pwm = pulseio.PWMOut(speaker_pin, variable_frequency=True, duty_cycle=0)
|
||||
pwm = pwmio.PWMOut(speaker_pin, variable_frequency=True, duty_cycle=0)
|
||||
|
||||
while True: # Loop forever...
|
||||
# Read photocell analog pin and convert voltage to frequency
|
||||
|
|
|
|||
|
|
@ -2,12 +2,12 @@
|
|||
# for Adafruit M0 boards
|
||||
|
||||
import board
|
||||
import pulseio
|
||||
import pwmio
|
||||
from adafruit_motor import servo
|
||||
from analogio import AnalogIn
|
||||
|
||||
# servo pin for the M0 boards:
|
||||
pwm = pulseio.PWMOut(board.A2, duty_cycle=2 ** 15, frequency=50)
|
||||
pwm = pwmio.PWMOut(board.A2, duty_cycle=2 ** 15, frequency=50)
|
||||
my_servo = servo.Servo(pwm)
|
||||
angle = 0
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import time
|
||||
import board
|
||||
import simpleio
|
||||
import pulseio
|
||||
import pwmio
|
||||
import digitalio
|
||||
|
||||
# PWM is not available on Trinket D1
|
||||
|
|
@ -10,7 +10,7 @@ speaker_pin = board.D2 # PWM speaker
|
|||
pwm_leds = board.D4 # PWM "fading" LEDs
|
||||
|
||||
# initialize PWM for LEDs
|
||||
pwm = pulseio.PWMOut(pwm_leds, frequency=256, duty_cycle=50)
|
||||
pwm = pwmio.PWMOut(pwm_leds, frequency=256, duty_cycle=50)
|
||||
led_fade_delay = .001 # delay in seconds makes color fade visible
|
||||
led_fade_step = 1024 # fade amount
|
||||
|
||||
|
|
|
|||
|
|
@ -7,13 +7,13 @@ import math
|
|||
import random
|
||||
import time
|
||||
import board
|
||||
import pulseio
|
||||
import pwmio
|
||||
import displayio
|
||||
from adafruit_motor import servo
|
||||
import adafruit_imageload
|
||||
from adafruit_matrixportal.matrix import Matrix
|
||||
|
||||
pwm = pulseio.PWMOut(board.A4, duty_cycle=2 ** 15, frequency=50)
|
||||
pwm = pwmio.PWMOut(board.A4, duty_cycle=2 ** 15, frequency=50)
|
||||
jaw_servo = servo.Servo(pwm)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue