ARDUINO Projects

  • Voltmeter

    Homemade voltmeter it's very useful for Measuring battery voltage the devices for example 12v liquid aside battery or liop or you can make it as
    battery charger by reading the data sheet of the battery and copy the full charge battery voltage then make a little adjustment in the program code for
    disconnecting power when the battery voltage, reach or you can make it as battery protection circuit for example cut the power when the battery reach 3.0v and so on.

    Demonstration

    connect the positive of the battery to 100k resistor and the ground of the battery to 10k resistor with the Arduino then connect the resistors between each other and put a wire from analog pin A0 of the Arduino to the resistors connections after that make the connections wire between the LCD and the Arduino board like the image below.

    Post

    Arduino code
    #include <LiquidCrystal.h>
    				//RS,E,DB4,DB5,DB6,DB7)
    LiquidCrystal lcd(7, 8, 9, 10, 11, 12);
    int analogInput = A0;
    float vout = 0.0;
    float vin = 0.0;
    float R1 = 100000.0; // resistance of R1 (100K)
    float R2 = 10000.0; // resistance of R2 (10K)
    int value = 0;
    void setup(){
       pinMode(analogInput, INPUT);
       lcd.begin(16, 2);
       lcd.print("DC VOLTMETER");
    }
    void loop(){
       // read the value at analog input
       value = analogRead(analogInput);
       vout = (value * 5.0) / 1024.0; // convert to 5v scale
       vin = vout / (R2/(R1+R2)); //Equation to read the value between the resistors
       if (vin<0.09) {
       vin=0.0;//statement to quash undesired reading !
    } 
    lcd.setCursor(0, 1);
    lcd.print("INPUT V= ");
    lcd.print(vin);
    delay(500);
    }								
    

    voltmeter 7segment

    if you want to use 7segment instead of LCD 16x2 you need to use "SevSeg.h" library and the code also below.
    Install the 7segment library: SevSeg.h
    Arduino code
    #include "SevSeg.h"
    int pot=A0;
    float vout = 0.0;
    float vin = 0.0;
    float R1 = 100000.0; // resistance of R1 (100K) 
    float R2 = 10000.0; // resistance of R2 (10K) 
    int value = 0;
    SevSeg sevseg; 
    
    void setup() {
      byte numDigits = 3;// the number of digits 
      byte digitPins[] = {2, 3, 4 };// digit power pins
      byte segmentPins[] = {6, 7, 8, 9, 10, 11, 12, 13};// connect from A to P
      Serial.begin(9600);
      sevseg.begin(COMMON_ANODE, numDigits, digitPins, segmentPins);
      sevseg.setBrightness(90);
    }
    void loop()
    {
    
      // read the value at analog input
       value = analogRead(pot);
       vout = (value * 5.0) / 1024.0; 
       vin = vout / (R2/(R1+R2)); 
       if (vin<0.09) {
       vin=0.0;
    }
      sevseg.setNumber(vin,2);
      sevseg.refreshDisplay();
      Serial.println(vin);
    }