Hello, I’m not even sure if I used the right terminology in the thread title but what I’m trying to approach is I turned 17v into 5v with a voltage divider. That 17v comes from a 317 regulator with a potentiometer on the adjust pin. I understand the basic voltage per step code but is there a code to then turn that 5v ADC code into 0-17v? I appreciate your time, thank you.
Use the voltage divider ratio to the 5 volt result and You get the 17 volt range.
Default Aref (5volt) is potentially too unstable for voltage measurements.
You should use the stable (but not accurate) buildin ~1.1volt Aref for that.
That means you must drop that 17volt to about 1.1volt (not 5volt) with your voltage divider.
This (untested) example sketch shows you how.
Leo..
/*
0 - ~17volt voltmeter
works with 3.3volt and 5volt Arduinos
uses the stable internal ~1.1volt reference
10k resistor from A0 to ground, and 150k resistor from A0 to +supply
(1k8:27k or 2k2:33k are also valid 1:15 ratios)
100n capacitor from A0 to ground for stable readings
*/
float voltage;
void setup() {
Serial.begin(9600);
analogReference(INTERNAL); // use (INTERNAL1V1) for a Mega
}
void loop() {
voltage = analogRead(A0) * 0.01660 ; // calibrate by changing the last digit(s) of 0.0166
// print
Serial.print("The supply is ");
Serial.print(voltage);
Serial.println(" volt");
delay(1000); // remove when combine with other code
}