Would you please correct my code or make it better to read 16 analogue signals and store them in variables to be used in different steps in the code? I have made it like the one below. It works, but it sounds inelegant.
You seem to understand what an array is just one line later. So I don't understand what you were thinking here. When you find yourself adding numbers to variables names, stop and realize that what you want is an array.
float sensors[17];
But keep in mind that analogRead returns an int, storing that into a float is not going to magically add extra precision. It just wastes memory.
I am here seeking support because I am not great at software. I try and learn. However, I always get precise float readings from my sensors with any Arduino or ESP microcontroller unless I identify my variables as integers. please advise.
The range of values represented by an analogRead are capable of being precisely represented by float variables, but it isn't recommended to use them for this purpose, because the representation consumes twice as much memory as is necessary, and their manipulation is much slower than for simple integer types.
However, a byte variable is not capable of representing the full range of an analogRead.
That's really interesting @anon56112670; they are measuring pressure and current, so if it is more than 1.75 amp, another action must be taken. any recommendation, please.
A float variable is quite capable of representing precise ADC values beyond 16 bits.
The IEEE754 32 bit representation has a 23 bit mantissa (fraction)
So what? analogRead returns an integer number. Putting it into a float is not going to suddenly magically make it more precise. It's not going to start suddenly interpolating between integer numbers and giving you any decimal places?
I was simply countering the assertion that making a float somehow makes the value less precise.
Whilst that may be a wider truth, in this specific instance, it's false.
I'm not advocating their use (far from it), merely pointing-out a falsehood, or, at best, a half-truth (no pun intended)