Hello
I have what is probably an odd question, but I was curious...
What would happen if I put a digital signal into an analog input and did an analogRead?
What would happen if I did the opposite If I had my analog input set to digitalRead, but put an analog signal in?
Is there a way for me to determine (using arduino only - no other equipment) if an input is analog or digital?
Thanks!
What would happen if I put a digital signal into an analog input and did an analogRead?
It would return a value of either 0 or 1023 depending if it were high or low.
What would happen if I did the opposite
Up to a threshold voltage it would read low and after that it would read high. Minimum and maximum threshold voltages are quoted in the data sheet but there is a grey area that would depend on a lot of factors.
Is there a way for me to determine (using arduino only - no other equipment) if an input is analog or digital
Put it in an analogue input read the analogue value and if the returned numbers are not 1023 or zero then you have an analogue signal.
Thanks! That is very helpful.
For testing if it is digital or analog, would I want to take multiple readings and see if they stayed consistently at that that 0 or 1023 level? If it is an analog signal that just is 0 or 1023 it would stay consistent whereas a digital signal would be jumping between the two at a quick rate, right? Any recommendations on the interval between taking each of the multiple readings?
If it is an analog signal that just is 0 or 1023 it would stay consistent whereas a digital signal would be jumping between the two at a quick rate, right?
Wrong.
Only if the signal is changing will you see a change. There is no difference between a static analogue signal set at 5V and a static digital signal set at logic high. Therefore you can not spot it until it moves.
It is a most odd thing to want to do, if you actually want to do this then I would suggest you are going about things incorrectly.
Thanks for the answer. It will be a changing signal, which I should have clarified.
I have a very specific reason for doing it this way. I realize it sounds crazy/wrong though and I appreciate the help.
Cheers!