I am using Adafruit Feather M4 Express to read buttons, switches, encoders and potentiometers and control some LEDs of a control panel. I am running into issues with the pin management.

  • I have 5 encoders (2 pins each), 10 buttons and 10 switches, 3 analog inputs from potentiometers.
  • I use MCP23017 over the I2C to read the buttons and switches. (Pins: 17, 18)
  • The analog signals are connected to the analog pins of the microcontroller. (Pins: 5, 6 plus 7, 8 for second control panel)
  • To drive few LED, one of them using digital drive signal from the microcontroller and the others with a LED driver chip TLC59711. (Pins: 19, 20, 21)
  • I use the SPI bus to communicate to a slave device. (Pins: 11, 12, 13, 22)


Since I want to reuse this board to interface a different control panel with slightly different setup, I have the following questions:

  1. Can I connect TLC59711 to the SPI bus to save two extra pins?
  2. I have a Schmitt trigger (SN74HC) connected to the encoder pins for the first control panel. I need extra analog pins for the second control panel. What effect does simply connecting the analog signal to the Schmitt trigger have?
  3. If I cannot use the same analog pin for reading analog signal for one control panel and for the other read encoder signals through the schmitt trigger, what would be the easiest and fail-proof way of multiplexing this pin for 2 different purposes, without having to add extra complexity to the design?
  • 1
    \$\begingroup\$ 1) Do you mean TLC59711 as a chip or the specific module which contains the chip? Do you have free pins for all the chip select signals? 2) Analog signal, to Schmitt trigger input? Or output? Which IC you have, how are you using it now, so what do you mean with this question? 3) Use a bigger MCU board that suits better to the purpose you need, like build your own with everything you need. Why did you select the current MCU board to begin with or why do you have to keep using it? Please note, not many are familiar which MCU that board has and is this more about Arduino or not. \$\endgroup\$
    – Justme
    Jan 18 at 8:55
  • \$\begingroup\$ @Justme 1) Yes, as a chip. As you can see in the picture, pins 20 and 21 are meant for the TLC chip. But I do not see a chip select pin for this IC. 2) For one use-case, I want to read digital input and for another use-case I want to read analog signal. Both on the same pin #7. Since I do not want to redesign my board for the 2 use-cases, the question is, can I read the analog signal which would be routed through the schmitt trigger? 3) Since the idea is to use my existing Adafruit Feather boards, this option is rules out. \$\endgroup\$
    – dreamcoder
    Jan 18 at 9:11
  • \$\begingroup\$ This is the pinout for the Feather M4 : learn.adafruit.com/assets/111181 \$\endgroup\$
    – dreamcoder
    Jan 18 at 9:11
  • \$\begingroup\$ 1) What do you mean you can't see a chip select for which IC? Do you understand the basics of SPI? 2) You are already using a Schmitt trigger, but basically, is your question what does a Schmitt trigger do to an input signal passing through a Schmitt trigger? Which IC is it? SN74HC tells nothing, exact type is required. \$\endgroup\$
    – Justme
    Jan 18 at 9:22
  • \$\begingroup\$ @Justme 1) cdn-shop.adafruit.com/datasheets/tlc59711.pdf - There is no chip select pin for this IC. 2) thats right. I am curious how the analog signal is affected when passing through Schmitt trigger. This is the part number: SN74HC14DBR \$\endgroup\$
    – dreamcoder
    Jan 18 at 9:35

2 Answers 2

  1. Not really, at least not directly, because the chip has no chip select or latch pin. After it sees data being clocked in, it will have an internal timeout after which it latches data in. If SPI is used with other devices, you need to gate the clock so the chip cannot see data transfers to other chips.

  2. Schmitt triggers are digital buffers with input hysteresis. It simply means input voltage must go high enough for the output to go high, and input voltage must go low enough for the output to go low. If the input floats between these two input thresholds, the output keeps state. So no, there is no way to read an analog signal through a Schmitt trigger buffer like the 74HC14, it will square it up into digital signal for you.

  3. It depends what you mean by extra complexity. Add jumpers or switches to select between the two signal sources for a pin. Add a multiplexer IC to select between the two signal sources for a pin, and select the mode in software. Add a three-state buffer between 74HC14 output and MCU input to use it for other purposes while the buffer is not an output.


I have a Schmitt trigger (SN74HC) connected to the encoder pins...

  • When you configure a GPIO as an Digital Input, there is already an internal Schmitt Trigger, there is no need for external Schmitt Trigger.
  • When you configure a GPIO as Analog Input, signal go directly to the ADC input without passing through any other circuit (other than internal protection resistor).

This is clearly illustrated in Figure 32-2. Overview of ATSAMD51 datasheet.

ATSAMD51 GPIO peripheral block diagram

I have 5 encoders (2 pins each), 10 buttons ...

If you have are running out of pins, instead of connection 10 buttons to 10 GPIOs, you could configure an analog pin and connect multiple buttons to the same analog pin as per what I described here. This will free-up 8 to 9 pins for other purposes.

Using Analog Input for reading multiple button states

the others with a LED driver chip TLC59711...

If you have a lot of LEDs in your design, instead of using external driver chip, you could take a look at an old technique called Charlieplexing, it allows you to drive n2 - n LEDs only with n GPIO pins. You can take a look at one of my project where I drive 12 LEDs with 4 GPIOs.

Charlieplexing for using 4 GPIOs to drive 12 LEDs


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.