Can someone help me make a flowchart using this coding arduino?

#include <LiquidCrystal.h>

const int LM35 = A0;
const int motor = 13;
const int LedRed = 12;
const int LedGreen = 11;

LiquidCrystal lcd(2, 3, 4, 5, 6, 7);

void setup() {
Serial.begin(9600);
lcd.begin(16, 2);
lcd.print("Automated Plant");
lcd.setCursor(0,1);
lcd.print("Watering System!");
pinMode(motor, OUTPUT);
pinMode(LedRed, OUTPUT);
pinMode(LedGreen, OUTPUT);
delay(2000);
lcd.clear();
lcd.print("Temp= ");
lcd.setCursor(0,1);
lcd.print("WaterPump= ");
}

void loop() {

int value = analogRead(LM35);
float Temperature = value * 500.0 / 1023.0;
lcd.setCursor(6,0);
lcd.print(Temperature);
lcd.setCursor(11,1);

if (Temperature > 50){
digitalWrite(motor, HIGH);
digitalWrite(LedRed, HIGH);
digitalWrite(LedGreen, LOW);
lcd.print("ON ");
}
else {
digitalWrite(motor, LOW);
digitalWrite(LedRed, LOW);
digitalWrite(LedGreen, HIGH);
lcd.print("OFF");
}

delay(1000);
}

You want to create a flowchart after writing the program ? That seems the wrong way round to me. How did you know how it would operate before writing the program ?

Have you tried searching the forum for other topics involving flowcharts ?

Start your own flowchart and show it when you encounter problems.

Use a flowchart or graphics editor or draw it on paper.

i want to learn from this code how to do a flowchart.

Did you write the code ?

Hi @.
I use and I like to make fluxograms using this site:
https://app.diagrams.net/

RV mineirin

PS:
Example of part of um flowchart written by mim.

here you go (to help you get started)

image

1 Like

You can make good flow charts with Word

Example:
image

Why is the an End block when the sketch never ends ?

This flowchart is trivial.
The Setup() portion is simply each instruction, no decisions (if's) etc.

The loop has only one decision (green block in post #8.
left side of the decision is for temperature >50
(
digitalWrite(motor, HIGH);
digitalWrite(LedRed, HIGH);
digitalWrite(LedGreen, LOW);
lcd.print("ON ");
}

[quote="syzwnzhr, post:1, topic:883070"]
if (Temperature > 50){
digitalWrite(motor, HIGH);
digitalWrite(LedRed, HIGH);
digitalWrite(LedGreen, LOW);
lcd.print("ON ");
}
the right isde of the decision is code in the else braces ()

I think the key here is for you to read each line and understand what each line of code does. Then you can work on what the program does.

Flowcharts can be more or less detailed. In many cases it's sufficient to reflect the program structure with loops and decisions only. The remaining statement sequences can stay compact blocks with some verbose description.

Just an example of the look, :wink: .