I am trying to figure this out without an array, but not sure where to start if that’s even possible. I don’t need anyone to post the code for me, but maybe a general direction on where to begin would be helpful, or pointers to references I can use to learn.
I have a voltage that I want to measure under load in a certain way (say 5v), it stays stable under load with a bit of a voltage drop for each device added. This changes my maximum voltage that can be reported because I want my maximum reported voltage dependent on number of devices dropping it.
5v 1 device makes the range 2.5v to 4.8v
5v input 2 devices makes the range 2.5v to 4.6v
pulling off the 2nd device brings the voltage back up to 4.8v ( I then want to use this new max value for the range)
Essentially I want to measure the voltage first, then store a variable holding that value as current maximum.
Then I want to apply a load that will drop the voltage.
I want to measure that drop with an analog read, which I know how to do, and report that drop to the serial monitor, along with the new maximum.
Then I want to add a load and sample the voltage again and use the new stable voltage under load as a new maximum to drive a new min/max range from there.
Then remove a load and see if I can restore my range to the previous range dynamically.
That’s the simplification. I want to do this for multiple loads.