Arduino Forum

Using Arduino => LEDs and Multiplexing => Topic started by: higgenkreuz_007 on Sep 13, 2019, 04:27 am

Title: Digital vs Analog Input
Post by: higgenkreuz_007 on Sep 13, 2019, 04:27 am
Hello,

I am using Arduino Leonardo for my project. I need to read distinct values from my piezo knock sensor, that is, not only do I want to detect a knock but I also want to know how hard the knock was. It works well on the analog inputs as I am getting values ranging from 0 to 1000 some but I am running out of them, I would like to read about 10 knock sensors.

My question is; is it possible to use digital inputs to get those values as well? My understanding is that it only reads HIGH and LOW (on or off) values, but maybe these digital values can be described to translate to a number on a spectrum, similar to the analog input.

Thanks in advance, your help is much appreciated.
Title: Re: Digital vs Analog Input
Post by: Grumpy_Mike on Sep 13, 2019, 08:09 am
Quote
My question is; is it possible to use digital inputs to get those values as well?
No.

To get more analogue inputs use an analogue multiplexer in front of one or more inputs. However as the number of sensors you want to measure increases the frequency which you can read them at decreases and you might miss some knocks or only read the trailing part of the pulse giving you an incorrect value.

To counter this you could fit an external fast analogue to digital converter on the SPI pins.
Title: Re: Digital vs Analog Input
Post by: HKJ-lygte on Sep 13, 2019, 08:41 am
The Mega32U4 processor supports way more analog inputs than is marked on the Arduino circuit board, this means you can find analog inputs for all your 10 sensors.

From the Leonardo documentation: Analog Inputs: A0-A5, A6 - A11 (on digital pins 4, 6, 8, 9, 10, and 12)