Skip to content

Commit 0a031e7

Browse files
committed
Merge remote-tracking branch 'adafruit/master'
2 parents c17a603 + 0ec11a7 commit 0a031e7

File tree

24 files changed

+2509
-306
lines changed

24 files changed

+2509
-306
lines changed
Binary file not shown.
Lines changed: 75 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,75 @@
1-
/*
2-
SerialNINAPassthrough - Use esptool to flash the ESP32 module
3-
For use with PyPortal, Metro M4 WiFi...
4-
5-
Copyright (c) 2018 Arduino SA. All rights reserved.
6-
7-
This library is free software; you can redistribute it and/or
8-
modify it under the terms of the GNU Lesser General Public
9-
License as published by the Free Software Foundation; either
10-
version 2.1 of the License, or (at your option) any later version.
11-
12-
This library is distributed in the hope that it will be useful,
13-
but WITHOUT ANY WARRANTY; without even the implied warranty of
14-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15-
Lesser General Public License for more details.
16-
17-
You should have received a copy of the GNU Lesser General Public
18-
License along with this library; if not, write to the Free Software
19-
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20-
*/
21-
22-
#include <Adafruit_NeoPixel.h>
23-
24-
unsigned long baud = 115200;
25-
26-
Adafruit_NeoPixel pixel = Adafruit_NeoPixel(1, 2, NEO_GRB + NEO_KHZ800);
27-
28-
29-
void setup() {
30-
Serial.begin(baud);
31-
pixel.begin();
32-
pixel.setPixelColor(0, 10, 10, 10); pixel.show();
33-
34-
while (!Serial);
35-
pixel.setPixelColor(0, 50, 50, 50); pixel.show();
36-
37-
delay(100);
38-
SerialNina.begin(baud);
39-
40-
pinMode(13, OUTPUT);
41-
pinMode(NINA_GPIO0, OUTPUT);
42-
pinMode(NINA_RESETN, OUTPUT);
43-
44-
// manually put the ESP32 in upload mode
45-
digitalWrite(NINA_GPIO0, LOW);
46-
47-
digitalWrite(NINA_RESETN, LOW);
48-
delay(100);
49-
digitalWrite(NINA_RESETN, HIGH);
50-
pixel.setPixelColor(0, 20, 20, 0); pixel.show();
51-
delay(100);
52-
}
53-
54-
void loop() {
55-
while (Serial.available()) {
56-
pixel.setPixelColor(0, 10, 0, 0); pixel.show();
57-
SerialESP32.write(Serial.read());
58-
}
59-
60-
while (SerialNina.available()) {
61-
pixel.setPixelColor(0, 0, 0, 10); pixel.show();
62-
Serial.write(SerialNina.read());
63-
}
64-
}
1+
/*
2+
SerialNINAPassthrough - Use esptool to flash the ESP32 module
3+
For use with PyPortal, Metro M4 WiFi...
4+
5+
Copyright (c) 2018 Arduino SA. All rights reserved.
6+
7+
This library is free software; you can redistribute it and/or
8+
modify it under the terms of the GNU Lesser General Public
9+
License as published by the Free Software Foundation; either
10+
version 2.1 of the License, or (at your option) any later version.
11+
12+
This library is distributed in the hope that it will be useful,
13+
but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15+
Lesser General Public License for more details.
16+
17+
You should have received a copy of the GNU Lesser General Public
18+
License along with this library; if not, write to the Free Software
19+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20+
*/
21+
22+
#include <Adafruit_NeoPixel.h>
23+
24+
unsigned long baud = 115200;
25+
26+
#if defined(ADAFRUIT_FEATHER_M4_EXPRESS) || defined(ADAFRUIT_PYBADGE_M4_EXPRESS) || defined(ADAFRUIT_PYGAMER_M4_EXPRESS)
27+
// Configure the pins used for the ESP32 connection via
28+
#define SerialESP32 Serial1
29+
#define SPIWIFI SPI // The SPI port
30+
#define SPIWIFI_SS 13 // Chip select pin
31+
#define ESP32_RESETN 12 // Reset pin
32+
#define SPIWIFI_ACK 11 // a.k.a BUSY or READY pin
33+
#define ESP32_GPIO0 10
34+
#define NEOPIXEL_PIN 8
35+
#endif
36+
37+
Adafruit_NeoPixel pixel = Adafruit_NeoPixel(1, NEOPIXEL_PIN, NEO_GRB + NEO_KHZ800);
38+
39+
40+
void setup() {
41+
Serial.begin(baud);
42+
pixel.begin();
43+
pixel.setPixelColor(0, 10, 10, 10); pixel.show();
44+
45+
while (!Serial);
46+
pixel.setPixelColor(0, 50, 50, 50); pixel.show();
47+
48+
delay(100);
49+
SerialESP32.begin(baud);
50+
51+
pinMode(SPIWIFI_SS, OUTPUT);
52+
pinMode(ESP32_GPIO0, OUTPUT);
53+
pinMode(ESP32_RESETN, OUTPUT);
54+
55+
// manually put the ESP32 in upload mode
56+
digitalWrite(ESP32_GPIO0, LOW);
57+
58+
digitalWrite(ESP32_RESETN, LOW);
59+
delay(100);
60+
digitalWrite(ESP32_RESETN, HIGH);
61+
pixel.setPixelColor(0, 20, 20, 0); pixel.show();
62+
delay(100);
63+
}
64+
65+
void loop() {
66+
while (Serial.available()) {
67+
pixel.setPixelColor(0, 10, 0, 0); pixel.show();
68+
SerialESP32.write(Serial.read());
69+
}
70+
71+
while (SerialESP32.available()) {
72+
pixel.setPixelColor(0, 0, 0, 10); pixel.show();
73+
Serial.write(SerialESP32.read());
74+
}
75+
}

CPX_Marble_Maze/README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
## Code for the Adafruit Learning System guide Gyroscopic Marble Maze
2+
3+
See the full tutorial at https://learn.adafruit.com/gryo-marble-maze/
4+
5+
The **code.py** file should be copied onto the **CIRCUITPY** flash drive that appears
6+
when you plug the CircuitPlayground Express into your computer via a known
7+
good USB cable.
8+
9+
If the only drive name you get is named **CPLAYBOOT**, CircuitPython may not be loaded
10+
on the board. You can load CircuitPython as
11+
[per this guide](https://learn.adafruit.com/adafruit-circuit-playground-express/circuitpython-quickstart).
12+
Then you should be able to see the **CIRCUITPY** drive when connected via USB.
13+
14+
CircuitPython resources are at https://CircuitPython.Org/
15+
16+
Code written by Dano Wall and Mike Barela for Adafruit Industries.
17+
18+
MIT License, please attribute.
19+
20+
Support Open Source development by buying your materials at [Adafruit.com](https://www.adafruit.com/).

CPX_Marble_Maze/code.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# CircuitPython code for the Gyroscopic Marble Maze
2+
# Adafruit Industries, 2019. MIT License
3+
import time
4+
import board
5+
import pulseio
6+
from adafruit_motor import servo
7+
import simpleio
8+
from adafruit_circuitplayground.express import cpx
9+
10+
# create a PWMOut object on Pin A2.
11+
pwm1 = pulseio.PWMOut(board.A1, duty_cycle=2 ** 15, frequency=50)
12+
pwm2 = pulseio.PWMOut(board.A2, duty_cycle=2 ** 15, frequency=50)
13+
14+
# Create a servo object, my_servo.
15+
my_servo1 = servo.Servo(pwm1)
16+
my_servo2 = servo.Servo(pwm2)
17+
18+
NUM_READINGS = 8
19+
roll_readings = [90] * NUM_READINGS
20+
pitch_readings = [90] * NUM_READINGS
21+
22+
def Average(lst):
23+
return sum(lst) / len(lst)
24+
25+
while True:
26+
x, y, z = cpx.acceleration # x = green
27+
print((x, y, z))
28+
29+
roll = simpleio.map_range(x, -9.8, 9.8, 0, 180)
30+
roll_readings = roll_readings[1:]
31+
roll_readings.append(roll)
32+
roll = Average(roll_readings)
33+
34+
print(roll)
35+
36+
my_servo1.angle = roll
37+
38+
pitch = simpleio.map_range(y, -9.8, 9.8, 0, 180)
39+
pitch_readings = pitch_readings[1:]
40+
pitch_readings.append(pitch)
41+
pitch = Average(pitch_readings)
42+
43+
print(pitch)
44+
45+
my_servo2.angle = pitch
46+
47+
time.sleep(0.05)
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
## Code for the Adafruit Learning System guide CircuitPython Powered AT Hand-Raiser
2+
3+
See the full tutorial at https://learn.adafruit.com/AT-Hand-Raiser/
4+
5+
The **code.py** file should be copied onto the **CIRCUITPY** flash drive that appears
6+
when you plug the CircuitPlayground Express into your computer via a known
7+
good USB cable.
8+
9+
If the only drive name you get is named **CPLAYBOOT**, CircuitPython may not be loaded
10+
on the board. You can load CircuitPython as
11+
[per this guide](https://learn.adafruit.com/adafruit-circuit-playground-express/circuitpython-quickstart).
12+
Then you should be able to see the **CIRCUITPY** drive when connected via USB.
13+
14+
CircuitPython resources are at https://CircuitPython.Org/
15+
16+
Code written by Bill Binko.
17+
18+
MIT License, please attribute.
19+
20+
Support Open Source development by buying your materials at [Adafruit.com](https://www.adafruit.com/).

0 commit comments

Comments
 (0)