DC-voltmeter with 4 channels

#include <LiquidCrystal.h>

// number of analog samples to take per reading, per channel
#define NUM_SAMPLES 10
// voltage divider calibration values
#define DIV_1    11.1346
#define DIV_2    11.1969
#define DIV_3    11.0718
#define DIV_4    11.0718
// ADC reference voltage / calibration value
#define V_REF    4.991

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
int sum[4] = {0};                // sums of samples taken
unsigned char sample_count = 0;  // current sample number
float voltage[4] = {0.0};        // calculated voltages
char l_cnt = 0;                  // used in 'for' loops

void setup()
{
    lcd.begin(16, 2);
}

void loop()
{
    // take a number of analog samples and add them up
    while (sample_count < NUM_SAMPLES) {
        // sample each channel A2 to A5
        for (l_cnt = 0; l_cnt < 4; l_cnt++) {
            sum[l_cnt] += analogRead(A2 + l_cnt);
        }
        sample_count++;
        delay(10);
    }
    // calculate the voltage for each channel
    for (l_cnt = 0; l_cnt < 4; l_cnt++) {
        voltage[l_cnt] = ((float)sum[l_cnt] / (float)NUM_SAMPLES * V_REF) / 1024.0;
    }
    // display voltages on LCD
    // each voltage is multiplied by the resistor network
    // division factor to calculate the actual voltage
    // voltage 1 - A (pin A2)
    lcd.setCursor(0, 0);
    lcd.print("A ");
    lcd.print(voltage[0] * DIV_1, 1);
    lcd.print("V ");
    // voltage 2 - B (pin A3)
    lcd.setCursor(8, 0);
    lcd.print("B ");
    lcd.print(voltage[1] * DIV_2, 1);
    lcd.print("V ");
    // voltge 3 - C (pin A4)
    lcd.setCursor(0, 1);
    lcd.print("C ");
    lcd.print(voltage[2] * DIV_3, 1);
    lcd.print("V ");
    // voltage 4 - D (pin A5)
    lcd.setCursor(8, 1);
    lcd.print("D ");
    lcd.print(voltage[3] * DIV_4, 1);
    lcd.print("V ");
    // reset count and sums
    sample_count = 0;
    for (l_cnt = 0; l_cnt < 4; l_cnt++) {
        sum[l_cnt] = 0;
    }
}

this is a code for measuring DC voltage ( voltmeter ) , using Arduino , with 4 channels
I have done the project for my school electronics class ,but i need more explanations about the code and how it works , please , any help is appreciated

Moderator edit:
</mark> <mark>[code]</mark> <mark>

</mark> <mark>[/code]</mark> <mark>
tags added.

So, you wrote the code, but don't know why you wrote it the way you did?

Or are you just wanting us to tell you what someone else's code does, so you can "prove" to your instructor that you wrote it?

You won't find me helping you to be dishonest.

lol , come on mate :/ the instructor knows that iam not the owner of the code :) I just have done this one : http://startingelectronics.com/projects/arduino-projects/arduino-4-channel-LCD-voltmeter/ but as a beginner I want to more understand the code , and I don't think i did something wrong :/ thanks anyway :)

the instructor knows that iam not the owner of the code

So you did not actually do the project after all, despite what you said.

I hope that you made a donation to Starting Electronics on the page that you linked to.

i have already started learning aruino :slight_smile: and this why i am here in this forum ! ,just to learn
also l’ve watched so many people in this forum who done similar projects that are already exist ,any way thanks for all

OSOO: i have already started learning aruino :) and this why i am here in this forum ! ,just to learn also l've watched so many people in this forum who done similar projects that are already exist ,any way thanks for all

I'd be more than willing to help you understand ANY of the examples that came with the Arduino IDE. I'm not against learning.