Add ESP32-S2 template examples.

This commit is contained in:
Kattni Rembor 2022-03-04 14:50:05 -05:00
parent 66ff8628ca
commit a616e6c91e
5 changed files with 71 additions and 1 deletions

View file

@ -1,4 +1,3 @@
# SPDX-FileCopyrightText: 2021 Kattni Rembor for Adafruit Industries
# SPDX-License-Identifier: MIT
"""

View file

@ -0,0 +1,17 @@
# SPDX-FileCopyrightText: 2022 Kattni Rembor for Adafruit Industries
# SPDX-License-Identifier: MIT
"""CircuitPython Analog In Voltage Example for ESP32-S2"""
import time
import board
import analogio
analog_pin = analogio.AnalogIn(board.A0)
def get_voltage(pin):
return (pin.value * 2.57) / 51000
while True:
print(get_voltage(analog_pin))
time.sleep(0.1)

View file

@ -0,0 +1,16 @@
# SPDX-FileCopyrightText: 2021 Kattni Rembor for Adafruit Industries
# SPDX-License-Identifier: MIT
"""
CircuitPython Capacitive Touch Pin Example for ESP32-S2.
Print to the serial console when one pin is touched.
"""
import time
import board
import touchio
touch = touchio.TouchIn(board.D8)
while True:
if touch.value:
print("Pin touched!")
time.sleep(0.1)

View file

@ -0,0 +1,19 @@
# SPDX-FileCopyrightText: 2021 Kattni Rembor for Adafruit Industries
# SPDX-License-Identifier: MIT
"""
CircuitPython Capacitive Two Touch Pin Example for ESP32-S2
Print to the serial console when a pin is touched.
"""
import time
import board
import touchio
touch_one = touchio.TouchIn(board.D8)
touch_two = touchio.TouchIn(board.D5)
while True:
if touch_one.value:
print("Pin one touched!")
if touch_two.value:
print("Pin two touched!")
time.sleep(0.1)

View file

@ -0,0 +1,19 @@
# SPDX-FileCopyrightText: 2022 Kattni Rembor for Adafruit Industries
# SPDX-License-Identifier: MIT
"""
CircuitPython Digital Input Example - Blinking an LED using the built-in button.
"""
import board
import digitalio
led = digitalio.DigitalInOut(board.LED)
led.direction = digitalio.Direction.OUTPUT
button = digitalio.DigitalInOut(board.BUTTON)
button.switch_to_input(pull=digitalio.Pull.UP)
while True:
if not button.value:
led.value = True
else:
led.value = False