I've found this code below, but I can't figure out how it works. Can someone explain to me the flow of the program?
#include <LiquidCrystal.h>
LiquidCrystal lcd(2, 3, 10, 7, 5, 4);
int mem=0;
void setup() {
pinMode (12,OUTPUT);
pinMode(13,OUTPUT);
// initialize the LED pin as an output:
// initialize serial communications:
Serial.begin(9600);
lcd.begin(16, 2);
}
void loop() {
lcd.setCursor(12,1);
int se25 = analogRead(A4);
int se50 = analogRead(A3);
int se75 = analogRead(A5);
int se100 = analogRead(A2);
if(se100>=1000){lcd.print("100% ");mem=100; }
else if(se75>=1000){lcd.print("75% ");mem=75; }
else if(se50>=1000){lcd.print("50% ");mem=50; }
else if(se25>=1000){lcd.print("25% ");mem=25; }
else{lcd.print("emty");mem=0;}
if(se100<1000&&se75<1000&&se50<1000&&se25<1000){
digitalWrite(13,LOW);
lcd.setCursor(12,1);
lcd.print("emty");
}
if(digitalRead(6)==HIGH){digitalWrite(13,LOW);}
if(digitalRead(6)==LOW&&mem>0)
{// read the value of the potentiometer:
int tempw = 0;
//digitalWrite(12,LOW);
int tempa = analogRead(A1);
delay(20);
int tempb = analogRead(A1);
delay(20);
int tempc = analogRead(A1);
delay(20);
int tempd = analogRead(A1);
delay(20);
int tempe = analogRead(A1);
delay(20);
int tempf = analogRead(A1);
delay(20);
int avg = ((tempa + tempb + tempc + tempd + tempe + tempf ) / 6);
int temp = avg;
// map it to the range of the analog out:
temp = map(temp, 0, 1023, 0, 4900);
float tempx = temp * (0.1);
// change the analog out value:
int tempy=analogRead(A0);
tempy = map(tempy, 0, 1023, 0, 150);
// print the results to the serial monitor:
lcd.setCursor(0,0);
lcd.print("act T=" );
lcd.print(tempx);
lcd.print("'C " );
lcd.setCursor(0,1);
lcd.print("set T=");
lcd.print(tempy);
// Serial.println("'C ");
lcd.print("'C ");
if(tempy<=tempx){digitalWrite(13,LOW);}
if(tempy>tempx){digitalWrite(13,HIGH);}
delay(200);
}
}