I am working on a circuit and I am a bit stuck on how to do the ADC part. I am using an ATTINY85 and using the internal ADC to take a measurement.
There are 3 inputs to the circuit, VIN, Signal and GND. VIN can be a voltage between 4.5 - 12VDC, Signal is a voltage between 0-100% of VIN, this what I want to read, and GND is obvious.
VIN goes through an LDO to power the ATTiny at 3.3V, so I need to turn my signal into a 0-3.3V value. For example, say VIN is 9V and Signal is 4.5V, then I need the input to the ADC to be 1.65V. How do I do that? If VIN was a fixed value I could do it easily, but I can´t figure out how to do it when VIN can change.
Any help kindly appreciated.