The Adafruit Hallowing M4 is a feature-filled development board, including four capacitve touch "teeth" at the bottom of it's skull-shaped circuit board.
CircuitPython has a nifty module for working cap touch pins, touchio
. However, the Hallowing M4 uses an Atmel SAMD51, which doesn't handle cap touch in hardware (unlike the SAMD21 in the Hallowing M0). If you try to use the cap touch pins without some additional setup, you'll get an error.
import board
import touchio
touch = touchio.TouchIn(board.TOUCH1)
Traceback (most recent call last):
File "<stdin>", line 4, in <module>
ValueError: No pulldown on pin; 1Mohm recommended
To fix this, you have to pull down a specific pin, board.CAP_PIN
, to enable the cap touch capability on those pins. That looks like this:
import board
import digitalio
import touchio
cap_pin = digitalio.DigitalInOut(board.CAP_PIN)
cap_pin.direction = digitalio.Direction.OUTPUT
cap_pin.value = False
touch = touchio.TouchIn(board.TOUCH1)
Or, more succinctly:
import board
from digitalio import DigitalInOut
import touchio
cap_pin = DigitalInOut(board.CAP_PIN)
cap_pin.switch_to_output(value=False)
touch = touchio.TouchIn(board.TOUCH1)
Once this is done, you can use touchio
with the board.TOUCHX
pins.
There are four touch pins on the Hallowing M4. In CircuitPython, these pins have a couple of definitions in the board
module: board.A2
/board.TOUCH1
, board.A3
/board.TOUCH2
, board.A4
/board.TOUCH3
, board.A5
/board.TOUCH4
.
If you attempt to use the speaker connector, you'll probably find that no sounds play. You have to enable the speaker explicitly! This is easy to do:
import board
from digitalio import DigitalInOut
speaker_enable = DigitalInOut(board.SPEAKER_ENABLE)
speaker_enable.switch_to_output(value=True)
Once this is done, the speaker will work. You can toggle the value of speaker_enable.value
from True
(speaker is on) to False
(speaker is off) once you've done this.