dawso
March 31, 2024, 7:44pm
1
#include <millisDelay.h>
int signal = 7;
int valve = 8;
millisDelay valveDelay;
int start = 0;
void setup()
{
pinMode(signal, INPUT);
pinMode(valve, OUTPUT);
digitalWrite(valve, LOW);
start.valveDelay(20000);
}
void loop()
{
(digitalWrite(valve, LOW));
}
{
if (digitalRead(signal) == LOW)
{
digitalWrite(signal,LOW);
}
}
else
{
digitalWrite(valve, HIGH);
start.valveDelay(20000);
if (valveDelay.justFinshed());
digitalWrite (valve, LOW);
}
}
}
b707
March 31, 2024, 7:49pm
3
You obviously lost some of the code when you copied it.
Please check the number of opening and closing parentheses {
}
- they must match.
Also read the forum rules and insert the code as a new message using a code tags
Juraj
March 31, 2024, 7:49pm
4
valveDelay.start(20000);
?
If you use the format feature in the IDE (cntl + T), you will see that in your loop there are more braces (opening and closing) than necessary.
And when posting code on the forum, use the " < code > " feature on the toolbar.
#include <millisDelay.h>
int signal = 7;
int valve = 8;
millisDelay valveDelay;
int start = 0;
void setup()
{
pinMode(signal, INPUT);
pinMode(valve, OUTPUT);
digitalWrite(valve, LOW);
start.valveDelay(20000);
}
void loop(){
digitalWrite(valve, LOW);
if (digitalRead(signal) == LOW)
{
digitalWrite(signal, LOW);
}
else
{
digitalWrite(valve, HIGH);
start.valveDelay(20000);
if (valveDelay.justFinshed());
digitalWrite (valve, LOW);
}
}
pert
March 31, 2024, 7:55pm
6
I moved your topic to an appropriate forum category @dawso .
In the future, please take some time to pick the forum category that best suits the subject of your topic. There is an "About the _____ category " topic at the top of each category that explains its purpose.
This is an important part of responsible forum usage, as explained in the "How to get the best out of this forum " guide . The guide contains a lot of other useful information. Please read it.
Thanks in advance for your cooperation.
dawso
March 31, 2024, 8:02pm
7
That is all of the code. there is the right amount of { for this code
dawso
March 31, 2024, 8:04pm
8
When i had tried that code the IDE gave me a error of Compilation error: request for member 'valveDelay' in 'start', which is of non-class type 'int'. what should I do.
Thank you!
b707
March 31, 2024, 8:08pm
9
It is obviously is not true, your loop()
contains a four {
and six }
b707
March 31, 2024, 8:29pm
11
It looks like this is one of the libraries designed to make it easier for beginners to use millis. For me, this is definitely a harmful thing.
As a result, beginners cannot even write commands in this simple library correctly.
I think @Juraj indicated the correct syntax in #4
Hi @dawso
welcome to the arduino-forum
There are still some things to learn
Like not posting pictures of code.
The bad code was already posted, or was it not?
The corrected code should be posted as code, or should I say a code-block, either way would be more helpful.
a7
2 Likes
Sure it is
In this case I decided to post the wrong code and the brace-corrected side by side for educational purposes to make directly visible what is wrong
in this case simply posting the corrected code would make it harder to see what is wrong.
anyway here is the code as code-section
#include <millisDelay.h>
int signal = 7;
int valve = 8;
millisDelay valveDelay;
int start = 0;
void setup()
{ // opening brace of void setup()
pinMode(signal, INPUT);
pinMode(valve, OUTPUT);
digitalWrite(valve, LOW);
start.valveDelay(20000);
} // closing brace of void setup()
void loop()
{ // opening brace of void loop()
(digitalWrite(valve, LOW));
if (digitalRead(signal) == LOW)
{
digitalWrite(signal, LOW);
}
else
{
digitalWrite(valve, HIGH);
start.valveDelay(20000);
if (valveDelay.justFinshed()); //<= semicolon makes if useless
digitalWrite (valve, LOW);
}
} // closing brace of void loop()
Hi, @dawso
Welcome to the forum.
See also FAQ - Arduino Forum for general rules on forum behavior and etiquette.
Hello,
Welcome to the Arduino Forum.
This guide explains how to get the best out of this forum. Please read and follow the instructions below.
Being new here you might think this is having rules for the sake of rules, but that is not the case. If you don’t follow the guidelines all that happens is there is a long exchange of posts while we try to get you to tell us what we need in order to help you, which is frus…
This link to how to use if statement may help.
The Arduino programming language Reference, organized into Functions, Variable and Constant, and Structure keywords.
Tom...
dawso
April 1, 2024, 12:11pm
16
After i had tired all of these codes that were posted the IDE said that there was a error and it had said Compilation error: request for member 'valveDelay' in 'start', which is of non-class type 'int'. Does anyone know what is wrong. P.S. with the right amount of brackets
b707
April 1, 2024, 12:18pm
17
Do you read the advices?
This question have been answered in the thread - see the #4
dawso
April 1, 2024, 12:24pm
18
I did the advices and it gave me a error of Compilation error: cannot convert 'millisDelay::justFinished' from type 'bool (millisDelay::)()' to type 'boo. What should i do
dawso
April 1, 2024, 12:30pm
19
I had got it working. I just wanted to say thank you to everyone that help me fix this issue I am very appreciated to everyone
Hi, @dawso
Please post your working code for others that may have this programming problem.
Thanks.. Tom..
dawso
April 6, 2024, 5:21pm
21
this is the final copy
#include <millisDelay.h>
int signal = 7;
int valve = 8;
millisDelay valveDelay;
int start = 0;
void setup()
{
pinMode(signal, INPUT);
pinMode(valve, OUTPUT);
digitalWrite(valve, LOW);
valveDelay.start(60000);
}
void loop()
{
(digitalWrite(valve, HIGH));
if (digitalRead(signal) == LOW)
{
digitalWrite(signal, LOW);
}
else
{
digitalWrite(valve, HIGH);
valveDelay.start(60000);
if (valveDelay.justFinished());
digitalWrite (valve, LOW);
}
}
Hi,
Please post your working code in code tags.
To add code please click this link;
See also FAQ - Arduino Forum for general rules on forum behavior and etiquette.
Hello,
Welcome to the Arduino Forum.
This guide explains how to get the best out of this forum. Please read and follow the instructions below.
Being new here you might think this is having rules for the sake of rules, but that is not the case. If you don’t follow the guidelines all that happens is there is a long exchange of posts while we try to get you to tell us what we need in order to help you, which is frus…
Tom...