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:

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: .

TempCtrl

Had to try that flowcharter. That the nicest one online that I've seen.

1. In Flow Chart Programming , the solution of a problem is described by the interconnections of a set of pre-defined ‘Geometrical Figures’ . The flow chart is a helpful tool for writing the assembly language or HLL codes. It is a good practice that we make a flow chart for every program we write and the professional people usually do it. A flow chart helps remembering the logic of the solution of the problem and assists in carrying out quick modification of the program in later times.

2. The symbols, names and functions of these figures are included in Fig-1. There is no ‘translation program’ for converting the ‘Flow Chart’ into machine codes/HLL codes.

Figure-1:

3. Example of a Flow Chart (Fig-2) that describes the process of blinking L (built-in LED of UNO) for 5 times at 1-sec interval.

flowBlinkL
Figure-2:

4. Line-to-Line Coding of Fig-2 (don't worry for the Labels and goto; they will be removed in Step-5).

void setup()
{
L1: Serial.begin(9600);
  pinMode(13, OUTPUT);
  byte counter = 0;
  //------------------------
L2: digitalWrite(13, HIGH);
  delay(1000);
  digitalWrite(13, LOW);
  delay(1000);
  //------------------------
L3: counter++;
L4: if (counter != 5)
  {
    goto L2;
  }
L5: ;
}
void loop()
{

}

5. Optimization of the sketch of Step-4 after removing of labels and goto statement. (Note that using of goto statement in programming is discouraged; however, it is a helpful tool for debugging a complicated non-functioning program and I used it a lot during the development phase of the Monitor Program for an 8086 based Trainer.)

void setup()
{
  Serial.begin(9600);  //L1:
  pinMode(13, OUTPUT);
  byte counter = 0;
  //------------------------
  do  //L2: - L5:
  {
    digitalWrite(13, HIGH);
    delay(1000);
    digitalWrite(13, LOW);
    delay(1000);
    counter++;
  }
  while (counter != 5);
}

void loop()
{

}

6. Now carry out reverse engineering and try to draw Flow Chart for the codes of your sketch of Post-1. I can help you if you briefly describe the functioning of your sketch.

1 Like

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.