Hi all new here ,is it posible to indicate the voltage of a 13v battery using a single led.steady on for 13v blinks 1000 for 12 and blinks 500 for 11v,sorry for asking but new to this also my flashlight has this and i find it very useful ,really apreciate.
blinks 1000 what? what is the magnitude
the same for 500, 500 what?
You're gonna count? ![]()
Also you have not made clear if you're looking for an Arduino based solution or not.
13v ledpin high ,12v ledpinhigh delay 1000 ledpinlow1000 ,11v ledpin high500 ledpinlow500
With a voltage divider you can do it.
Post your sketch, well formated, with well-tempered comments and in so called code tags "< code >" to see how we can help.
1000 pulses per second a lot for human "consumption" but might be useful for an electronic eye.
You could have a look at my heartBeat class, which can be used to indicate different patterns for different states. Used it to indicate the current used in a project. The blink rate was linearly mapped with the current, so 10.9 A was 10.9 blinks per second.
Question: you seem to want a logarithmic / exponential scale. Why?
Yes it is possible
Which Arduino are you using?
I never heard of a 13V battery, what is this battery?
Do you mean a car battery, typically over 14V fully charged?
Anyway, as already mentioned, it’s easy enough with a voltage divider, or a ‘ladder’ in this case of three resistors. I d suggest three 10k presets so that you can fine tune to get precision.
And to avoid the snag of irritating switching / flickering at the transition points you’ll need either additional components to make a Schmitt trigger circuit on the input, or, simpler, some additional logic in your Arduino sketch to provide that hysteresis.
battery is lifepo i now i cannot use multiple delays but here is my code.
int battery = 0;
int ledPin = 13; // LED connected to digital pin 13
void setup() {
pinMode(ledPin, OUTPUT);
// initialize serial communications:
Serial.begin(9600);
}
void loop()
{
battery=analogRead(0);
if (battery < 1000) {
digitalWrite(ledPin, HIGH);
digitalWrite(ledPin, LOW);
}
else {
digitalWrite(ledPin, LOW);
}
if (battery < 500) {
digitalWrite(ledPin, HIGH);
delay(500);
digitalWrite(ledPin, LOW);
delay(500);
}
else {
digitalWrite(ledPin, LOW);
}
if (battery < 300) {
digitalWrite(ledPin, HIGH);
delay(200);
digitalWrite(ledPin, LOW);
delay(200);
}
else {
digitalWrite(ledPin, LOW);
}
}
arduino for now is a uno,i will use some a voltage divider but i dont now how to use multiple delays.
Please edit ( #10) post so all of the code is presented as such. Mark it and click the <code> button. Thanks.
Just modify your code little bit.
For 20k:10k voltage divider for example:
int battery = analogRead(A0) * 15 / 1023;
if (battery <= 11) {
digitalWrite(ledPin, HIGH);
delay(500);
digitalWrite(ledPin, LOW);
delay(500);
}
else if (battery <= 12) {
digitalWrite(ledPin, HIGH);
delay(1000);
digitalWrite(ledPin, LOW);
delay(1000);
}
else {
digitalWrite(ledPin, HIGH);
delay(1000);
}
You must post you code accordind to forum rules so that it is readable without errors.
In the Arduino IDE, click on Edit, then Copy for Forum, that will copy you code for use on this foeum.
Then come back here and do a simple paste. You will now see the code posted in a window.
int battery = 0;
int ledPin = 13; // LED connected to digital pin 13
void setup() {
pinMode(ledPin, OUTPUT);
// initialize serial communications:
Serial.begin(9600);
}
void loop()
{
battery=analogRead(0);
int battery = analogRead(A0) * 15 / 1023;
if (battery <= 10) {
digitalWrite(ledPin, HIGH);
delay(100);
digitalWrite(ledPin, LOW);
delay(100);
}
else if (battery <= 11) {
digitalWrite(ledPin, HIGH);
delay(500);
digitalWrite(ledPin, LOW);
delay(500);
}
else if (battery <= 12) {
digitalWrite(ledPin, HIGH);
delay(1000);
digitalWrite(ledPin, LOW);
delay(1000);
}
else {
digitalWrite(ledPin, HIGH);
delay(1000);
}}
thank you ,the use is for visual voltage reading from meters away will post the project on future
Actually,
float battery = analogRead(A0) * 15 / 1023;
would be more correct for those thresholds
[quote="kostaskef, post:15, topic:1370747"]
age reading
[/quote]thank you will change variables
Until you post your code correctly we won't know what you have tried.
