Skip to content

Commit a616e6c

Browse files
committed
Add ESP32-S2 template examples.
1 parent 66ff862 commit a616e6c

File tree

5 files changed

+71
-1
lines changed
  • Adafruit_Feather_TFT_ESP32-S2/storage
  • CircuitPython_Templates
    • analog_voltage_values_ESP32-S2
    • cap_touch_one_pin_ESP32-S2
    • cap_touch_two_pins_ESP32-S2
    • digital_input_built_in_button_led

5 files changed

+71
-1
lines changed

Adafruit_Feather_TFT_ESP32-S2/storage/boot.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
# SPDX-FileCopyrightText: 2021 Kattni Rembor for Adafruit Industries
32
# SPDX-License-Identifier: MIT
43
"""
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# SPDX-FileCopyrightText: 2022 Kattni Rembor for Adafruit Industries
2+
# SPDX-License-Identifier: MIT
3+
"""CircuitPython Analog In Voltage Example for ESP32-S2"""
4+
import time
5+
import board
6+
import analogio
7+
8+
analog_pin = analogio.AnalogIn(board.A0)
9+
10+
11+
def get_voltage(pin):
12+
return (pin.value * 2.57) / 51000
13+
14+
15+
while True:
16+
print(get_voltage(analog_pin))
17+
time.sleep(0.1)
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# SPDX-FileCopyrightText: 2021 Kattni Rembor for Adafruit Industries
2+
# SPDX-License-Identifier: MIT
3+
"""
4+
CircuitPython Capacitive Touch Pin Example for ESP32-S2.
5+
Print to the serial console when one pin is touched.
6+
"""
7+
import time
8+
import board
9+
import touchio
10+
11+
touch = touchio.TouchIn(board.D8)
12+
13+
while True:
14+
if touch.value:
15+
print("Pin touched!")
16+
time.sleep(0.1)
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# SPDX-FileCopyrightText: 2021 Kattni Rembor for Adafruit Industries
2+
# SPDX-License-Identifier: MIT
3+
"""
4+
CircuitPython Capacitive Two Touch Pin Example for ESP32-S2
5+
Print to the serial console when a pin is touched.
6+
"""
7+
import time
8+
import board
9+
import touchio
10+
11+
touch_one = touchio.TouchIn(board.D8)
12+
touch_two = touchio.TouchIn(board.D5)
13+
14+
while True:
15+
if touch_one.value:
16+
print("Pin one touched!")
17+
if touch_two.value:
18+
print("Pin two touched!")
19+
time.sleep(0.1)
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# SPDX-FileCopyrightText: 2022 Kattni Rembor for Adafruit Industries
2+
# SPDX-License-Identifier: MIT
3+
"""
4+
CircuitPython Digital Input Example - Blinking an LED using the built-in button.
5+
"""
6+
import board
7+
import digitalio
8+
9+
led = digitalio.DigitalInOut(board.LED)
10+
led.direction = digitalio.Direction.OUTPUT
11+
12+
button = digitalio.DigitalInOut(board.BUTTON)
13+
button.switch_to_input(pull=digitalio.Pull.UP)
14+
15+
while True:
16+
if not button.value:
17+
led.value = True
18+
else:
19+
led.value = False

0 commit comments

Comments
 (0)