Skip to content

Commit 8cf70d6

Browse files
committed
2 parents d766d55 + eb103e9 commit 8cf70d6

39 files changed

Lines changed: 912 additions & 5 deletions

File tree

.github/workflows/githubci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
strategy:
88
fail-fast: false
99
matrix:
10-
arduino-platform: ["uno", "nrf52832", "cpx_ada", "pyportal", "protrinket_3v", "protrinket_5v", "metro_m0", "esp8266", "esp32", "trinket_3v", "trinket_5v", "gemma", "flora", "feather32u4", "feather_m0_express", "gemma_m0", "trinket_m0", "hallowing_m0", "monster_m4sk", "hallowing_m4", "neotrellis_m4", "pybadge", "cpb", "cpc", "funhouse", "magtag"]
10+
arduino-platform: ["uno", "nrf52832", "cpx_ada", "pyportal", "protrinket_3v", "protrinket_5v", "metro_m0", "esp8266", "esp32", "trinket_3v", "trinket_5v", "gemma", "flora", "feather32u4", "feather_m0_express", "gemma_m0", "trinket_m0", "hallowing_m0", "monster_m4sk", "hallowing_m4", "hallowing_m4_tinyusb", "neotrellis_m4", "pybadge", "cpb", "cpc", "funhouse", "magtag"]
1111

1212
runs-on: ubuntu-18.04
1313

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import time
2+
import board
3+
from digitalio import DigitalInOut, Direction
4+
5+
# LED setup for onboard LED
6+
led = DigitalInOut(board.LED)
7+
led.direction = Direction.OUTPUT
8+
9+
while True:
10+
11+
led.value = True
12+
print("led on")
13+
time.sleep(1)
14+
15+
led.value = False
16+
print("led off")
17+
time.sleep(1)
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import time
2+
import board
3+
from digitalio import DigitalInOut, Direction, Pull
4+
5+
# LED setup for onboard LED
6+
led = DigitalInOut(board.LED)
7+
led.direction = Direction.OUTPUT
8+
9+
# button setup
10+
switch = DigitalInOut(board.D4)
11+
switch.direction = Direction.INPUT
12+
switch.pull = Pull.UP
13+
14+
# variable for number count
15+
n = 0
16+
17+
while True:
18+
19+
# when switch is NOT pressed...
20+
if switch.value:
21+
# LED is off
22+
led.value = False
23+
# when switch is pressed...
24+
else:
25+
# LED is on
26+
led.value = True
27+
# value of n increases by 1
28+
n += 1
29+
# n is printed to the REPL
30+
print("led ON %i" % n)
31+
# delay
32+
time.sleep(0.01)
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
'''Adapted from the example code DM_Mic_Sound_Level_Plot.py
2+
https://github.com/adafruit/Adafruit_Learning_System_Guides/
3+
blob/master/PDM_Microphone/PDM_Mic_Sound_Level_Plot.py '''
4+
5+
import time
6+
import array
7+
import math
8+
import board
9+
import audiobusio
10+
import pwmio
11+
import simpleio
12+
13+
# LED setup
14+
led = pwmio.PWMOut(board.A1, frequency=5000, duty_cycle=0)
15+
16+
# Remove DC bias before computing RMS.
17+
def mean(values):
18+
return sum(values) / len(values)
19+
20+
def normalized_rms(values):
21+
minbuf = int(mean(values))
22+
samples_sum = sum(
23+
float(sample - minbuf) * (sample - minbuf)
24+
for sample in values
25+
)
26+
27+
return math.sqrt(samples_sum / len(values))
28+
29+
mic = audiobusio.PDMIn(board.MICROPHONE_CLOCK,
30+
board.MICROPHONE_DATA, sample_rate=16000, bit_depth=16)
31+
samples = array.array('H', [0] * 160)
32+
33+
while True:
34+
35+
mic.record(samples, len(samples))
36+
magnitude = normalized_rms(samples)
37+
print((magnitude,))
38+
39+
# mapping mic's level to LED PWM range
40+
mapped_value = simpleio.map_range(magnitude, 75 , 300, 0, 65535)
41+
42+
# sending mapped value to LED for PWM
43+
led.duty_cycle = int(mapped_value)
44+
# optional logging for mapped_value
45+
# print((mapped_value,))
46+
time.sleep(0.01)
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
'''Adapted from the Adafruit_CircuitPython_ESP32SPI
2+
library example esp32spi_simpletest.py:
3+
https://github.com/adafruit/Adafruit_CircuitPython_ESP32SPI/
4+
blob/master/examples/esp32spi_simpletest.py '''
5+
6+
import board
7+
import busio
8+
from digitalio import DigitalInOut
9+
import adafruit_requests as requests
10+
import adafruit_esp32spi.adafruit_esp32spi_socket as socket
11+
from adafruit_esp32spi import adafruit_esp32spi
12+
13+
# Get wifi details and more from a secrets.py file
14+
try:
15+
from secrets import secrets
16+
except ImportError:
17+
print("WiFi secrets are kept in secrets.py, please add them there!")
18+
raise
19+
20+
print("Arduino Nano RP2040 Connect webclient test")
21+
22+
TEXT_URL = "http://wifitest.adafruit.com/testwifi/index.html"
23+
24+
# ESP32 pins
25+
esp32_cs = DigitalInOut(board.CS1)
26+
esp32_ready = DigitalInOut(board.ESP_BUSY)
27+
esp32_reset = DigitalInOut(board.ESP_RESET)
28+
29+
# uses the secondary SPI connected through the ESP32
30+
spi = busio.SPI(board.SCK1, board.MOSI1, board.MISO1)
31+
32+
esp = adafruit_esp32spi.ESP_SPIcontrol(spi, esp32_cs, esp32_ready, esp32_reset)
33+
34+
requests.set_socket(socket, esp)
35+
36+
if esp.status == adafruit_esp32spi.WL_IDLE_STATUS:
37+
print("ESP32 found and in idle mode")
38+
print("Firmware vers.", esp.firmware_version)
39+
print("MAC addr:", [hex(i) for i in esp.MAC_address])
40+
41+
for ap in esp.scan_networks():
42+
print("\t%s\t\tRSSI: %d" % (str(ap['ssid'], 'utf-8'), ap['rssi']))
43+
44+
print("Connecting to AP...")
45+
while not esp.is_connected:
46+
try:
47+
esp.connect_AP(secrets["ssid"], secrets["password"])
48+
except RuntimeError as e:
49+
print("could not connect to AP, retrying: ", e)
50+
continue
51+
print("Connected to", str(esp.ssid, "utf-8"), "\tRSSI:", esp.rssi)
52+
print("My IP address is", esp.pretty_ip(esp.ip_address))
53+
54+
print(
55+
"IP lookup adafruit.com: %s" % esp.pretty_ip(esp.get_host_by_name("adafruit.com"))
56+
)
57+
58+
print("Fetching text from", TEXT_URL)
59+
r = requests.get(TEXT_URL)
60+
print("-" * 40)
61+
print(r.text)
62+
print("-" * 40)
63+
r.close()
64+
65+
print("Done!")

Astrophotography_Tracker/code.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
microsteps = 64 # Microstepping resolution
1111
total_steps = steps * microsteps # Total microsteps per revolution
1212

13-
wait = 1/ ((gear_ratio * total_steps) / 86400)
13+
wait = 1/ ((gear_ratio * total_steps) / 86164.1)
1414

1515
step = digitalio.DigitalInOut(board.D6)
1616
direct = digitalio.DigitalInOut(board.D5)
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)