Skip to content

Commit 17a7132

Browse files
authored
Merge branch 'master' into master
2 parents e9d5e25 + a180e4c commit 17a7132

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+160285
-98
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from adafruit_circuitplayground.express import cpx
2+
3+
while True:
4+
if cpx.button_a:
5+
cpx.play_file("rise.wav")
6+
if cpx.button_b:
7+
cpx.play_file("dip.wav")
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from adafruit_circuitplayground.express import cpx
2+
3+
while True:
4+
if cpx.button_a:
5+
cpx.play_tone(260, 1)
6+
if cpx.button_b:
7+
cpx.play_tone(292, 1)

Adafruit_STEMMA_Speaker/dip.wav

25.9 KB
Binary file not shown.

Adafruit_STEMMA_Speaker/rise.wav

25.7 KB
Binary file not shown.

All_Seeing_Skull/All_Seeing_Skull.ino

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ void setup(void) {
8585
Serial.begin(115200);
8686
randomSeed(analogRead(A3)); // Seed random() from floating analog input
8787

88+
pinMode(MOTION_SENSOR_PIN, INPUT);
89+
8890
#ifdef DISPLAY_BACKLIGHT
8991
// Enable backlight pin, initially off
9092
pinMode(DISPLAY_BACKLIGHT, OUTPUT);

BLE_Client_Server/Eagle/CP_Solenoid3.brd

Lines changed: 1778 additions & 0 deletions
Large diffs are not rendered by default.

BLE_Client_Server/Eagle/CP_Solenoid3.sch

Lines changed: 6582 additions & 0 deletions
Large diffs are not rendered by default.

BLE_Client_Server/README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Adafruit Learning System tutorial - A CircuitPython BLE Client & Server
2+
3+
Use Bluetooth to turn a server on and off and actively sense the server's status light
4+
5+
Follow the Adafruit learn guide here: https://learn.adafruit.com/circuitpython-ble-client-server/
6+
7+
Adafruit invests time and resources providing this open source code,
8+
please support Adafruit and open-source hardware by purchasing
9+
products from [Adafruit](https://www.adafruit.com)!
10+
11+
MIT license, project and code by rdagger
12+
13+
All text above, and the splash screen below must be included in any redistribution
14+
15+
-----------------------
16+
If you are looking to make changes/additions, please use the GitHub Issues and Pull Request mechanisms.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

BLE_Client_Server/client.py

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
from time import sleep
2+
from adafruit_ble.uart_client import UARTClient
3+
from adafruit_ble.scanner import Scanner
4+
from adafruit_bluefruit_connect.packet import Packet
5+
from adafruit_bluefruit_connect.button_packet import ButtonPacket
6+
from adafruit_bluefruit_connect.color_packet import ColorPacket
7+
from neopixel import NeoPixel
8+
from board import NEOPIXEL, SWITCH
9+
from adafruit_debouncer import Debouncer
10+
from digitalio import DigitalInOut, Direction, Pull
11+
import adafruit_fancyled.adafruit_fancyled as fancy
12+
13+
pin = DigitalInOut(SWITCH) # Set up built-in pushbutton switch
14+
pin.direction = Direction.INPUT
15+
pin.pull = Pull.UP
16+
switch = Debouncer(pin)
17+
18+
pixels = NeoPixel(NEOPIXEL, 1) # Set up built-in NeoPixel
19+
20+
AQUA = 0x00FFFF # (0, 255, 255)
21+
GREEN = 0x00FF00 # (0, 255, 0)
22+
ORANGE = 0xFF8000 # (255, 128, 0)
23+
RED = 0xFF0000 # (255, 0, 0)
24+
BLUE = 0x0000FF # (0, 0, 255)
25+
26+
gradients = {'Off': [(0.0, RED), (0.75, ORANGE)],
27+
'On': [(0.0, GREEN), (1.0, AQUA)]}
28+
palette = fancy.expand_gradient(gradients['Off'], 30)
29+
30+
gamma_levels = (0.25, 0.3, 0.15)
31+
color_index = 1
32+
fade_direction = 1
33+
34+
TARGET = 'a0:b4:c2:d0:e7:f2' # CHANGE TO YOUR BLE ADDRESS
35+
36+
button_packet = ButtonPacket("1", True) # Transmits pressed button 1
37+
38+
scanner = Scanner() # BLE Scanner
39+
uart_client = UARTClient() # BLE Client
40+
41+
while True:
42+
uart_addresses = []
43+
pixels[0] = BLUE # Blue LED indicates disconnected status
44+
pixels.show()
45+
46+
# Keep trying to find target UART peripheral
47+
while not uart_addresses:
48+
uart_addresses = uart_client.scan(scanner)
49+
for address in uart_addresses:
50+
if TARGET in str(address):
51+
uart_client.connect(address, 5) # Connect to target
52+
53+
while uart_client.connected: # Connected
54+
switch.update()
55+
if switch.fell: # Check for button press
56+
try:
57+
uart_client.write(button_packet.to_bytes()) # Transmit press
58+
except OSError:
59+
pass
60+
# Check for LED status receipt
61+
if uart_client.in_waiting:
62+
packet = Packet.from_stream(uart_client)
63+
if isinstance(packet, ColorPacket):
64+
if fancy.CRGB(*packet.color).pack() == GREEN: # Color match
65+
# Green indicates on state
66+
palette = fancy.expand_gradient(gradients['On'], 30)
67+
else:
68+
# Otherwise red indicates off
69+
palette = fancy.expand_gradient(gradients['Off'], 30)
70+
71+
# NeoPixel color fading routing
72+
color = fancy.palette_lookup(palette, color_index / 29)
73+
color = fancy.gamma_adjust(color, brightness=gamma_levels)
74+
c = color.pack()
75+
pixels[0] = c
76+
pixels.show()
77+
if color_index == 0 or color_index == 28:
78+
fade_direction *= -1 # Change direction
79+
color_index += fade_direction
80+
81+
sleep(0.02)

BLE_Client_Server/server.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
from time import sleep
2+
from adafruit_ble.uart_server import UARTServer
3+
from adafruit_bluefruit_connect.packet import Packet
4+
from adafruit_bluefruit_connect.button_packet import ButtonPacket
5+
from adafruit_bluefruit_connect.color_packet import ColorPacket
6+
from board import A0, D13
7+
from analogio import AnalogIn
8+
from digitalio import DigitalInOut, Direction
9+
10+
led = AnalogIn(A0) # Initialize blue LED light detector
11+
12+
solenoid = DigitalInOut(D13) # Initialize solenoid
13+
solenoid.direction = Direction.OUTPUT
14+
solenoid.value = False
15+
16+
uart_server = UARTServer()
17+
18+
while True:
19+
uart_server.start_advertising() # Advertise when not connected.
20+
21+
while not uart_server.connected: # Wait for connection
22+
pass
23+
24+
while uart_server.connected: # Connected
25+
if uart_server.in_waiting: # Check BLE commands
26+
packet = Packet.from_stream(uart_server)
27+
if isinstance(packet, ButtonPacket):
28+
if packet.button == '1' and packet.pressed:
29+
solenoid.value = True # Activate solenoid for 1 second
30+
sleep(1)
31+
solenoid.value = False
32+
33+
led_intensity = led.value # Check blue LED detector intensity
34+
led_on = led_intensity > 1000
35+
# Color: red = off, green = on
36+
color_packet = ColorPacket((255 * int(not led_on), 255 * led_on, 0))
37+
try:
38+
uart_server.write(color_packet.to_bytes()) # Transmit state color
39+
except OSError:
40+
pass
41+
42+
sleep(.2)

CPB_Cauldron/CAD/CPX Cauldron.f3d

6.69 MB
Binary file not shown.

0 commit comments

Comments
 (0)