Skip to content

Commit 3255256

Browse files
authored
Merge branch 'master' into fix-pyportal-mqtt-sensor-node
2 parents 7e5fd71 + be00721 commit 3255256

File tree

5 files changed

+10250
-1
lines changed

5 files changed

+10250
-1
lines changed

Astrophotography_Tracker/code.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import time
2+
import board
3+
import digitalio
4+
5+
worm_ratio = 40/1
6+
belt_ratio = 100/60
7+
gear_ratio = worm_ratio * belt_ratio
8+
9+
steps = 200 # Steps per revolution
10+
microsteps = 64 # Microstepping resolution
11+
total_steps = steps * microsteps # Total microsteps per revolution
12+
13+
wait = 1/ ((gear_ratio * total_steps) / 86400)
14+
15+
step = digitalio.DigitalInOut(board.D6)
16+
direct = digitalio.DigitalInOut(board.D5)
17+
18+
step.direction = digitalio.Direction.OUTPUT
19+
direct.direction = digitalio.Direction.OUTPUT
20+
21+
direct.value = True
22+
23+
while True:
24+
step.value = True
25+
time.sleep(0.001)
26+
step.value = False
27+
time.sleep(wait - 0.001)

MIDI_Solenoid_Drum_Kit/code.py

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import time
2+
import board
3+
import digitalio
4+
import usb_midi
5+
import adafruit_midi
6+
from adafruit_midi.note_on import NoteOn
7+
8+
# pins for the solenoid output signals
9+
noid_pins = [board.D5, board.D6, board.D9, board.D10]
10+
11+
# array for the solenoids
12+
noids = []
13+
14+
# setup for the solenoid pins to be outputs
15+
for pin in noid_pins:
16+
noid = digitalio.DigitalInOut(pin)
17+
noid.direction = digitalio.Direction.OUTPUT
18+
noids.append(noid)
19+
20+
# MIDI note array
21+
notes = [60, 61, 62, 63]
22+
23+
# MIDI in setup
24+
midi = adafruit_midi.MIDI(midi_in=usb_midi.ports[0], in_channel=0)
25+
26+
# delay for solenoids
27+
speed = 0.03
28+
retract = 0
29+
30+
while True:
31+
32+
# msg holds MIDI messages
33+
msg = midi.receive()
34+
35+
for i in range(4):
36+
# states for solenoid on/off
37+
noid_output = noids[i]
38+
39+
# states for MIDI note recieved
40+
notes_played = notes[i]
41+
42+
# if NoteOn msg comes in and the MIDI note # matches with predefined notes:
43+
if isinstance(msg, NoteOn) and msg.note is notes_played:
44+
print(time.monotonic(), msg.note)
45+
46+
# solenoid is triggered
47+
noid_output.value = True
48+
# quick delay
49+
retract = time.monotonic()
50+
51+
# retracts solenoid using time.monotonic() to avoid delays between notes activating
52+
if (retract + speed) < time.monotonic():
53+
noid_output.value = False

MP3_Tap_Player/mp3_tap_player.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# MP3 playback with tap trigger
2-
# Works on M4 and nRF52840 based boards with accelerometer or Propmaker
2+
# Works on Feather M4 (or other M4 based boards) with Propmaker
33
import time
44
import board
55
import busio

0 commit comments

Comments
 (0)