Low voltage notification

hello all, i am new to the world of Arduino. :slight_smile:

I still can not program the Arduino, therefore I copy and paste the code from the Internet. I want to use the Arduino to indicate low voltage, there is a flashing light. I really want to merge www.arduino.cc/en/Tutorial/ReadAnalogVoltage and else - Arduino Reference and https://www.arduino.cc/en/Tutorial/Blink, but I do not know how. Do you know how to do it, or perhaps a code for me, I would find it fine. Thanks in advance!

greetings Hidde :slight_smile:

I want to use the Arduino to indicate low voltage

Low voltage from what? Relative to what?

there is a flashing light.

Where?

I really want to merge www.arduino.cc/en/Tutorial/ReadAnalogVoltage and else - Arduino Reference and https://www.arduino.cc/en/Tutorial/Blink, but I do not know how.

What are your requirements? There is no better time to learn than when you have a real goal.

Do you know how to do it

What is "it"?

or perhaps a code for me, I would find it fine.

I'm sure that it would, but you wouldn't have learned anything. Next project, you'd be back here with half baked requirements and no clue. Learn to write requirements, and the coding part will be easy.

PaulS:
Low voltage from what? Relative to what?
Where?
What are your requirements? There is no better time to learn than when you have a real goal.
What is "it"?
I'm sure that it would, but you wouldn't have learned anything. Next project, you'd be back here with half baked requirements and no clue. Learn to write requirements, and the coding part will be easy.

NOTE: i have translated the text with google translate

  1. low voltage from a battery
  2. From a led
  3. ?
  4. Quote
    I really want to merge www.arduino.cc/en/Tutorial/ReadAnalogVoltage and else - Arduino Reference and https://www.arduino.cc/en/Tutorial/Blink, but I do not know how.
  5. yes, you're right, but how i can learn it? i am Dutch

You can detect voltage levels up to 5V directly with the Arduino analog inputs, what voltage do you consider LOW?
What are the voltage and current requirements of the flashing light?

  1. yes, you're right, but how i can learn it? i am Dutch

There is an International section of the forum, where several languages are spoken. Perhaps you'd be more comfortable being able to post in your native language without having to translate.

Reading the battery voltage is easy - analogRead() (using a voltage divider if the battery voltage is higher than 5V.

Determining if the value is low is easy, using an if statement.

Blinking an LED is easy. The blink without delay example shows how. Putting the blink without delay code in the if statement body seems logical, so the LED only blinks when the voltage is low.

jcallen:
You can detect voltage levels up to 5V directly with the Arduino analog inputs, what voltage do you consider LOW?
What are the voltage and current requirements of the flashing light?

I mean with low 3V and with the led i mean the pin 13 led.

Hello everybody, my project is succesfully finished! I have learn the language a little bit and i can! The led blinks if the voltage is under 3 volts. Here the code:

// the setup routine runs once when you press reset:
void setup() {
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
}

void loop() {
int sensorValue = analogRead(A0);
float voltage = sensorValue * (5.0 / 1023.0);
Serial.println(voltage);
if (voltage <3.00
){ digitalWrite(13, HIGH);
delay(1000);
digitalWrite(13, LOW);
delay(1000);
}}

Next, learn how to make your code more readable. Tip, use ctrl+T. And for posting code, use code tags.

And I spot an error, the 1023 should be 1024 :wink:

And another tip, you don't need to put the read in a variable first. If you only use it once you can just do

float voltage = analogRead(A0) * 5.0 / 1024.0;

septillion:
Next, learn how to make your code more readable. Tip, use ctrl+T. And for posting code, use code tags.

And I spot an error, the 1023 should be 1024 :wink:

And another tip, you don't need to put the read in a variable first. If you only use it once you can just do

float voltage = analogRead(A0) * 5.0 / 1024.0;

thaks :slight_smile: