Help Arduino Compilation error: expected initializer before '.' token. Can any body help me with this

#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);
}
}
}

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

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);
  }
}

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.

That is all of the code. there is the right amount of { for this code

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!

It is obviously is not true, your loop() contains a four { and six }

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.

This link to how to use if statement may help.

Tom... :grinning: :+1: :coffee: :australia:

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

Do you read the advices?
This question have been answered in the thread - see the #4

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

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.. :grinning: :+1: :coffee: :australia:

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;

Tom... :grinning: :+1: :coffee: :australia: