Esempio n. 1
0
# Import required libraries for light sensor, thermistor, BLE radio, and neopixels
import time
import board
import analogio
import adafruit_thermistor
from adafruit_ble import BLERadio
from adafruit_ble.advertising.standard import ProvideServicesAdvertisement
from adafruit_ble.services.nordic import UARTService
import neopixel

# Setup the BLE radio
ble = BLERadio()
uart_server = UARTService()
advertisement = ProvideServicesAdvertisement(uart_server)
# Give your CPB a unique name between the quotes below
advertisement.complete_name = "AK_CPB"

# Setup the thermistor and light sensor
tmp = adafruit_thermistor.Thermistor(board.TEMPERATURE, 10000, 10000, 25, 3950)
light = analogio.AnalogIn(board.LIGHT)

# Setup neopixels
BLUE = (0, 0, 255)
NAVY = (0,0,128)
BLACK = (0, 0, 0)
leadColor = BLUE
chaseColor = NAVY
pauseTime = 0.1
pxl = neopixel.NeoPixel(board.NEOPIXEL, 10, brightness =0.1, auto_write = True)

# Neopixel pattern for BLE connection
Esempio n. 2
0
# Declare a NeoPixel object on NEOPIXEL_PIN with NUM_LEDS pixels,
# no auto-write.
# Set brightness to max, we'll control it later in the code
pixels = neopixel.NeoPixel(
    NEOPIXEL_PIN,
    NUM_LEDS,
    brightness=0.5,
    auto_write=False,
    #pixel_order=(1,0,2,3) #uncomment if using RGBW NeoPixels
)

ble = BLERadio()
uart_service = UARTService()
advertisement = ProvideServicesAdvertisement(uart_service)
advertisement.complete_name = "DingDong"


class RainbowFade(Animation):
    ''' fades the entire strip through the whole spectrum '''
    _color_index = 150  # choose start color (0-255)

    def __init__(self, pixel_object, speed, name):  # define animation
        super().__init__(pixel_object, speed=speed, color=WHITE, name=name)

    def draw(self):  # draw the animation
        ''' fades the entire strip through the whole spectrum '''
        self.color = colorwheel(self._color_index + 1)
        self._color_index = (self._color_index + 1) % 256
        self.fill(self.color)
Esempio n. 3
0
import time
import board
import digitalio
import adafruit_ble
from adafruit_ble.advertising import Advertisement
from adafruit_ble.advertising.standard import ProvideServicesAdvertisement
from adafruit_ble.services.standard.hid import HIDService
from adafruit_hid.keyboard import Keyboard
from adafruit_hid.keycode import Keycode

hid = HIDService()
advertisement = ProvideServicesAdvertisement(hid)
advertisement.complete_name = 'CIRCUITPY KEYBOARD'
advertisement.appearance = 961
ble = adafruit_ble.BLERadio()
if ble.connected:
    for c in ble.connections:
        c.disconnect()
ble.start_advertising(advertisement)
advertising = True
ble_keyboard = Keyboard(hid.devices)

button = digitalio.DigitalInOut(board.USR_BTN)
button.direction = digitalio.Direction.INPUT
button.pull = digitalio.Pull.UP

last_value = button.value

while True:
    if last_value != button.value:
        last_value = button.value
Esempio n. 4
0
# Only the packet classes that are imported will be known to Packet.
from adafruit_bluefruit_connect.button_packet import ButtonPacket
from adafruit_bluefruit_connect.color_packet import ColorPacket

import adafruit_fancyled.adafruit_fancyled as fancy
import adafruit_fancyled.fastled_helpers as helper
from audiopwmio import PWMAudioOut as AudioOut
from audiocore import WaveFile
import board
import time

ble = BLERadio()
uart_service = UARTService()
ble.name = "BabyYoda"
advertisement = ProvideServicesAdvertisement(uart_service)
advertisement.complete_name = "BabyYoda"

RainbowStripeColors = [
    0xFF0000, 0x000000, 0xAB5500, 0x000000, 0xABAB00, 0x000000, 0x00FF00,
    0x000000, 0x00AB55, 0x000000, 0x0000FF, 0x000000, 0x5500AB, 0x000000,
    0xAB0055, 0x000000
]

color = (0, 0, 255)

RED = (255, 0, 0)
ORANGE = (255, 50, 0)
YELLOW = (255, 165, 0)
GREEN = (0, 255, 0)
CYAN = (0, 255, 255)
BLUE = (0, 0, 255)
Esempio n. 5
0
import digitalio
import time
from digitalio import DigitalInOut, Direction, Pull
from adafruit_ble import BLERadio
from adafruit_ble.advertising.standard import ProvideServicesAdvertisement
from adafruit_ble.services.nordic import UARTService
from adafruit_bluefruit_connect.packet import Packet
from adafruit_bluefruit_connect.color_packet import ColorPacket
from adafruit_bluefruit_connect.button_packet import ButtonPacket

# setup bluetooth
ble = BLERadio()
uart_server = UARTService()
advertisement = ProvideServicesAdvertisement(uart_server)
# Give your CPB a unique name between the quotes below
advertisement.complete_name = "ProfGs-Tie"

run_animation = False
animation_number = -1

led_pin = board.A1  # which pin your pixels are connected to
num_leds = 5  # how many LEDs you have
brightness = 1.0  # 0-1, higher number is brighter
saturation = 255  # 0-255, 0 is pure white, 255 is fully saturated color
steps = 0.01  # how wide the bands of color are.
offset = 0  # cummulative steps
fadeup = True  # start with fading up - increase steps until offset reaches 1

# initialize list with all pixels off
palette = [0] * num_leds