Do you know how to make the circuit board for this code?
#include<LiquidCrystal.h> // include the library code for lcd
LiquidCrystal lcd(12, 11, 5, 4, 3, 2); //
#define echopin 9 // echo pin
#define trigpin 8 // Trigger pin
int maximumRange = 50;
long duration, distance;
void setup() {
lcd.begin(16,2);
Serial.begin (9600);
pinMode (trigpin, OUTPUT);
pinMode (echopin, INPUT );
pinMode (4, OUTPUT);
pinMode (13,OUTPUT);
}
void loop ()
{
{
digitalWrite(trigpin,LOW);
delayMicroseconds(2);
digitalWrite(trigpin,HIGH);
delayMicroseconds(10);
duration=pulseIn (echopin,HIGH);
distance= duration/58.2;
delay (50);
Serial.println(distance);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("WATER LEVEL :");
lcd.print(distance);
delay(0);
}
if (distance <= 90){
digitalWrite (13,HIGH);// connect to relay(motor)
digitalWrite (7,HIGH);
lcd.setCursor(0,1);
lcd.print("TANK IS FULL");
delay(0);
}
else if (distance >=10) {
digitalWrite (7,LOW); // connect to relay(motor)
digitalWrite (13,LOW);
lcd.setCursor(0,1);
lcd.print("PUMP STARTED");
delay(1000);
}
}
Yes. Post the schematic and I'm sure ppl will have ideas about how to make the circuit board.
a7
1 Like
I mean, draw the schematic diagram for the code provided.
Haha. OK I see.
Where did the code come from? Did not that source supply other information like the parts you need and... how they are to be connected to power and the Arduino?
What does the code do?
a7
gcjr
May 7, 2023, 2:52pm
6
mentalblack:
LiquidCrystal lcd(12, 11, 5, 4, 3, 2); //
#define echopin 9 // echo pin
#define trigpin 8 // Trigger pin
do you really need a schematic/PCB for this?
doesn't the above indicate how to connect an LCD and ultrasonic sensor?
Tell us exactly what you need.
Who wrote that sketch ?
What components do you have ?
mentalblack:
I wrote the sketch Sir.
You still mean you want us to draw a schematic diagram, right?
It is your code, your project. I don't see how you wrote all that the code with no idea of what you are connecting or how it should be connected.
Where did you learn how to write code for an LCD? Did none of those places show how to connect an LCD?
Where did you learn how to write code for an ultrasonic range finder? Did none of those places show how to connect an ultrasonic range finder?
How is the power to the pump being controlled?
You've recently added in some idea of solar panels being involved.
We could guess but maybe only come close enough to make providing such guess work a step in the wrong direction.
TBH your own guessing would be better than all of us doing.
a7
Do you mean flowchart?
Code doesn’t have "schematics", hardware does.
You START with a hardware schematic and write code to match the hardware. You don't write random code and then try and figure out what the hardware does. Hardware is a GIVEN!
Perhaps there is a language or terminology issue?
xfpd
May 7, 2023, 5:23pm
12
Drawing of idea.
[edit: needed a relay, added corrected debug code and this simulation ]
#include<LiquidCrystal.h> // include the library code for lcd
LiquidCrystal lcd(12, 11, 5, 4, 3, 2); // RS, EN, D4, D5, D6, D7 // VSS, RW, K - GND // VDD, A - 5V
#define echopin 9 // echo pin
#define trigpin 8 // Trigger pin
int maximumRange = 50;
long duration, distance;
void setup() {
randomSeed(analogRead(A0)); // debug
lcd.begin(16, 2);
Serial.begin (9600);
pinMode (trigpin, OUTPUT);
pinMode (echopin, INPUT );
pinMode (4, OUTPUT);
pinMode (13, OUTPUT);
}
void loop ()
{
digitalWrite(trigpin, LOW);
delayMicroseconds(2);
digitalWrite(trigpin, HIGH);
delayMicroseconds(10);
duration = pulseIn (echopin, HIGH);
distance = duration / 58.2;
delay (50);
distance = random(10, 100); // debug values for water level
Serial.println(distance);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("WATER LEVEL: ");
lcd.print(distance);
delay(10);
if (distance >= 90) {
digitalWrite (13, LOW); // turn LED OFF
digitalWrite (7, LOW); // disconnect relay(motor)
lcd.setCursor(0, 1);
lcd.print("TANK IS FULL");
delay(1000);
}
else if (distance <= 20) {
digitalWrite (7, HIGH); // connect relay(motor)
digitalWrite (13, HIGH); // turn LED ON
lcd.setCursor(0, 1);
lcd.print("PUMP STARTED");
delay(1000);
}
else if (distance > 10 && distance < 90)
digitalWrite(7, LOW); // pump is off
}
2 Likes
Ok, next step is actual part numbers and THEN we can talk wiring.
xfpd
May 29, 2023, 3:19pm
15
Is there a way for you to update this? The "END" is in a "connector" (circle) when it should be in a "terminator" oval (as the start is). I like it.
A flowchart is a type of diagram that represents a workflow or process. A flowchart can also be defined as a diagrammatic representation of an algorithm, a step-by-step approach to solving a task.
The flowchart shows the steps as boxes of various kinds, and their order by connecting the boxes with arrows. This diagrammatic representation illustrates a solution model to a given problem. Flowcharts are used in analyzing, designing, documenting or managing a process or program in various fields.
...
can you create a flowchart based on the information above?
xfpd
May 29, 2023, 4:56pm
19
No.
A flowchart is a description of your code in picture-form.
You can draw it by hand (you do not need to use a computer).
Start with a "terminal" symbol (latin for "end point").
initialize hardware and variables inside an "initialization" symbol
input and output inside rhomboid (slanted rectangle)
decisions (if..then, switch...case, while..do) inside a "decision" (rhombus)
process in a rectangle
loop using connectors (circle)
Make one. You will see how easy it is, and doing it will make you think about how your program works... or does not work.
system
Closed
November 25, 2023, 4:56pm
20
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.