I am working on a project using Force Sensors to build a keyboard for MD patients. I have connected the sensors (each with 4 input pins) to digital pins to Arduino Due. I want to adjust the threshold of the digital pins in order to cancel out the initial weight of a user's hand when using the keyboard. I have read that digital pins have a built-in threshold ("low"<0.3 Vcc and "high">0.6Vcc). I can't connect my sensors to Analog pins (due to needing 20 input pins), and was wondering if adjusting the threshold is possible? I have researched and found one project that used Analog pins and adjusted the threshold, which I am trying to emulate: https://www.instructables.com/Arduino-Programmable-Button-Panel-As-Keyboard/ P.S: I am a beginner at Arduino and would appreciate the help
1Could you consider using an analog multiplexer?– Edgar BonetMay 23, 2022 at 12:45
I like Edgar Bonet's idea. Backing up a bit more. Would it be easier for an MS patient to control a chorded keyboard?– st2000May 23, 2022 at 14:30
No, you cannot change these threshold. They are set by the digital input hardware (technically a Schmitt trigger) inside the microcontroller. They are not meant to be adjustable, since they are digital input, not analog inputs.
So you either need to build your own adjustable logic (involving opamps and variable resistors), feeding the output of that to the Arduino, or you need to use analog inputs.
I would suggest using the second method. You can extend the number of analog inputs basically by 2 means:
You can buy analog multiplexers. These are chips that can connect one analog input of the Arduino on one side to X pins on the other side. Most of them are controlled via digital pins. Then you cycle through each setting of the multiplexer to connect one sensor at a time and do a measurement on each of them. Each analog pin can be connected to one analog multiplexer
You can buy an external ADC board. These are often connected via interfaces like I2C or SPI (for example this one from Adafruit with 4 channels each). You can use multiple of them.