I took the LEDs out of the picture.. until I can dial in the voltage.. (at least 'close enough'..doesnt need to be perfect)
using this simple code.. I watched the serial monitor:
int voltagePin = 5;
int voltageVal = 0; // variable to store the value read
Serial.begin(9600); // setup serial
voltageVal = analogRead(voltagePin); // read the input pin
Serial.println(voltageVal); // debug value
if at 7.4v. I should be getting 1023..
and as I turn down lower.. the reading/output should also adjust (lower)..
however.. I dont get a change in the reading until I am under 5v+.. (which to me says the voltage divider is set up wrong)
as always.. I tried to read what I could (and understand).. and also give it a 'try' before asking to be spoon fed! lol
thanks.. makes sense.. as also takes care of the 'color' problem (as I can use a resistor to match that specific led's vF
I have +Vin (PSU +).. going to breadboard.. same row, next hole.. I have resistor (470 Ohm), in-line/same row after that second resistor leg (again same row).. I have the +Vout going to Arduino A5 pin.
still (same row) after the Vout to A5.. I have (last hole in row) 1 leg of resistor (1k Ohm)..going to another , new row.
In new row.. on 1 side of resistor.. I have -Vin lead (goes to PSU -).. on other side of resistor (same 1K Ohm) I have the -Vout to a GND pin on the Arduino
here is a different schematic.. more or less showing it how it is on the breadboard.. (maybe because Im using a BB I screwed it up?) (yes, I know you dont like breadboards.. its all I have!) LOL
Also.. can you dumb this up a bit? LOL.. or maybe give an explanation?
although a volt meter with an input impedance of 1K5 is a bit of a poor meter.
Im not sure what you mean? in any project "I" would use this in would be a 3.7v, 4.5v, 6v or 7.4 volt (the only battery packs I really use in my hobby).. mostly 7.4v Li-Ions.. but others have been used.
I want to light ALL leds if full juice.. and go down on the number of leds lit after that.. (reaching my cut-off/threshold)...which would leave the leds only 1 lit.
"input impedance of 1K5 " just means your meter draws a lot of current - in this 7.4V/1500 = 5mA, could use 4.7K.10K and cut that down to 0.5mA.
7.4 to 470, to 1K to gnd. Junction of 470/1K should be 5.03V if batteries were discharged and down at 3.7V. (7.4*1K)/(.47K + 1K)
Fresh batteries will be more like 8.4V tho, so 5.71V, dropping to ~5V when discharged.
Consider changing your R values to reflect that.
Hi, I have a problem also with a arduino voltmeter/ammeter that is part of a power supply I made.
I have written all the code connected it up and it reads the volts and amps pretty accurately on an lcd.
My problem is when i connect a load to the power supply the voltage drop shown on the lcd is no where near what it reads on a multimeter. ie. if I set the voltage to say 6.00 volts connect a 3.9ohm load the lcd shows 5.8 volts where as the multimeter shows something around 5.00 volts. and doesn't drop much more with bigger loads either.
Does anyone know why this might be?
thought the problem might be electrical but ill attatch the code for you to look at.
but I get about 1.1 amps when i do the maths there so its a little out.
// These constants won't change:
const int analogPin = A4; // pin that the sensor is attached to
const int ledPin = 6; // pin that the LED is attached to
const int threshold = 365; // an arbitrary threshold level that's in the range of the analog input
int analoginput0 = 3; //analoge pin 2
int analoginput1 = 4; //analoge pin 5
float vout1 = 0.0;
float vout2 = 0.0;
int value1 = 0;
int value2 = 0;
float R1 = 5100.0; // !! resistance of R1 !!
float R2 = 2193.0; // !! resistance of R2 !!
float vin1 = 0.0;
float vin2 = 0.0;
// initialize the LED pin as an output:
// initialize serial communications:
// declaration of pin modes
// read the value on analog input
value1 = analogRead(analoginput0); //voltage value
vout1 = (value1 * 4.555)/1023.0;
vin1 = vout1 / (R2/(R1+R2));
value2 = analogRead(analoginput1); //Amp output
vout2 = (value2 * 4.555)/1023.0; //4.555=voltage threshold (1023=4.555V);
vin2 = vout2*2; //vin2 = value2;
// read the value of the potentiometer:
int analogValue = analogRead(analogPin);
// if the analog value is high enough, sound alarm:
// if (analogValue > threshold)
if (vin2 > 3.2) // Set amp alarm value
digitalWrite; //(ledPin, HIGH); //ledpin for led
The 4.555 is the voltage I got when I measured the analogue input variable power supply and multimeter, so 1023 is reached at roughly 4.555 volts not 5 volts exactly, unless its the multimeter telling me different.
and I think i just added the *2 in there just to make the amps close to what it is ment to be. But yes i got a 0.5 ohm shunt on the ground rail.
Im no coding expert and just improvising where i can.
So I will change out the resistors to be 4.7k & 10k respectively.. and lets me keep the draw form the 'meter' low...
but why @ a stable 7.4v from the PSU am I getting readings of 1023 from +5v - +7.4v??
My guess is that either the resistors you are using are not really 470 ohms and 1K (e.g. the one you think is 1K is actually 10k, or the one you think is 470 ohms is actually 47 ohms), or you are using one of those breadboards that has a break in the middle of the 5v and gnd rails and you haven't taken account of that break (so the 1k resistor is not connected to ground).
Yeh the 4.55 might be a bit low but at the end of the day i have to calibrate it to something and thats the reading i get @ 1023, its really no big deal i can change it to 5 but is less accurate, according to my meter. But its doesn't have anything to do with the voltage drop issue, or lack of it should i say.