Go Down

Topic: Variable or field declared void (Read 270 times) previous topic - next topic

dwyerl2

I am having trouble trying to figure this error out. Thanks for any help in advance.

Arduino: 1.8.7 (Windows 8.1), Board: "Arduino/Genuino Uno"

C:\Users\dwyerlog\Documents\Arduino\Seed_Cleaner\Seedcleaner6.0\Seedcleaner6.0.ino: In function 'void infeedauger1()':

Seedcleaner6.0:75:6: error: variable or field 'outfeedauger' declared void

 void outfeedauger

      ^

Seedcleaner6.0:78:54: error: expected '}' before ';' token

   outfeeduplimitState = digitalRead(ulimitoutfeedPin);

                                                      ^

Seedcleaner6.0:105:1: error: expected '}' at end of input

 }

 ^

Seedcleaner6.0:105:1: error: expected '}' at end of input

Seedcleaner6.0:105:1: error: expected '}' at end of input

exit status 1
variable or field 'outfeedauger' declared void

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.


Code: [Select]
const int ulimitinfeedPin = 13;
const int llimitinfeedPin = 12;
const int infeedaugerPin = 9;
const int infeedHopperFullStatePin = 5;
int infeedfaultsignal = 3;
bool infeeduplimitState ;
bool infeedlowlimitState ;
bool infeedfaultSignal = LOW;
bool infeedauger = LOW;
bool infeedHopperFullState = LOW;

const int ulimitoutfeedPin = 11;
const int llimitoutfeedPin = 10;
const int outfeedaugerPin = 8;
const int outfeedHopperFullStatePin = 4;
int outfeedfaultsignal = 2;
bool outfeeduplimitState ;
bool outfeedlowlimitState ;
bool outfeedfaultSignal = LOW;
bool outfeedauger = LOW;
bool outfeedHopperFullState = LOW;
void setup()
{
  pinMode( ulimitinfeedPin, INPUT);
  pinMode(infeedaugerPin, OUTPUT);
  pinMode (llimitinfeedPin, INPUT);
  pinMode (infeedHopperFullStatePin, OUTPUT);
  pinMode (infeedfaultsignal, OUTPUT);

  pinMode( ulimitoutfeedPin, INPUT);
  pinMode(outfeedaugerPin, OUTPUT);
  pinMode (llimitoutfeedPin, INPUT);
  pinMode (outfeedHopperFullStatePin, OUTPUT);
  pinMode (outfeedfaultsignal, OUTPUT);
}


void loop() {
}
void infeedauger1 (){
 
  //read both limits at the start of the loop, then use the Status to do your control. ie, you take a snapshot of you project inputs.
  infeeduplimitState = digitalRead(ulimitinfeedPin);
  infeedlowlimitState = digitalRead(llimitinfeedPin);
  digitalWrite(infeedaugerPin, infeedauger);
{}
 if (infeeduplimitState == LOW && infeedlowlimitState == LOW) //hopper is full.
  {
    infeedauger = LOW;
    infeedfaultSignal = LOW;
    infeedHopperFullState = HIGH;
  }
  {
  if (infeeduplimitState == HIGH && infeedlowlimitState == HIGH) //Hopper is empty.
  {
    infeedauger = HIGH;
    infeedfaultSignal = LOW;
    infeedHopperFullState = LOW;
  }
  {
  if (infeeduplimitState == HIGH && infeedlowlimitState == LOW & infeedHopperFullState == LOW) //Hopper is filling
  {
    infeedauger = HIGH;
    infeedfaultSignal = LOW;
  }
  {
  if (infeeduplimitState == LOW && infeedlowlimitState == HIGH)  //not a possible combination when operating correctly.
  {
    infeedauger = LOW;
    infeedfaultSignal = HIGH;
  }
}

void outfeedauger
{
  //read both limits at the start of the loop, then use the Status to do your control. ie, you take a snapshot of you project inputs
  outfeeduplimitState = digitalRead(ulimitoutfeedPin);
  outfeedlowlimitState = digitalRead(llimitoutfeedPin);
  digitalWrite(outfeedaugerPin, outfeedauger);
{

  if (outfeeduplimitState == LOW && outfeedlowlimitState == LOW) //hopper is full.
  {
    outfeedauger = LOW;
    outfeedfaultSignal = LOW;
    outfeedHopperFullState = HIGH;
  }
  if (outfeeduplimitState == HIGH && outfeedlowlimitState == HIGH) //Hopper is empty.
  {
    outfeedauger = HIGH;
    outfeedfaultSignal = LOW;
    outfeedHopperFullState = LOW;
  }
  if (outfeeduplimitState == HIGH && outfeedlowlimitState == LOW & outfeedHopperFullState == LOW) //Hopper is filling
  {
    outfeedauger = HIGH;
    outfeedfaultSignal = LOW;
  }
  if (outfeeduplimitState == LOW && outfeedlowlimitState == HIGH)  //not a possible combination when operating correctly.
  {
    outfeedauger = LOW;
    outfeedfaultSignal = HIGH;
  }
}


larryd

#1
Dec 09, 2018, 10:53 pm Last Edit: Dec 09, 2018, 10:53 pm by larryd
void outfeedauger
{
. . .
}

Is this the proper format for a function?



No technical PMs.
If you are asked a question, please respond with an answer.
If you are asked for more information, please supply it.
If you need clarification, ask for help.

slipstick

Your brackets {} are in a mess. Try using Auto Format (Ctrl+T) and you should see the problems.

Also even when you get the brackets sorted out "void outfeedauger {" is invalid.

Steve

Deva_Rishi

this line although it compiles and it is technically speaking incorrect and will not cause any strange behavior is disturbing to me
Code: [Select]
{}
To 'Correct' you have to be Correct. (and not be condescending..)

dwyerl2

I changed it to void outfeedauger1(){ and I still get an error but I donot get one on void infeedauger1(){
 I auto formatted and I am still getting these errors.

Arduino: 1.8.7 (Windows 8.1), Board: "Arduino/Genuino Uno"

C:\Users\dwyerlog\Documents\Arduino\Seed_Cleaner\Seedcleaner6.0\Seedcleaner6.0.ino: In function 'void infeedauger1()':

Seedcleaner6.0:75:29: error: a function-definition is not allowed here before '{' token

       void outfeedauger1 () {

                             ^

Seedcleaner6.0:105:9: error: expected '}' at end of input

         }

         ^

Seedcleaner6.0:105:9: error: expected '}' at end of input

Seedcleaner6.0:105:9: error: expected '}' at end of input

exit status 1
a function-definition is not allowed here before '{' token

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.


Code: [Select]
const int ulimitinfeedPin = 13;
const int llimitinfeedPin = 12;
const int infeedaugerPin = 9;
const int infeedHopperFullStatePin = 5;
int infeedfaultsignal = 3;
bool infeeduplimitState ;
bool infeedlowlimitState ;
bool infeedfaultSignal = LOW;
bool infeedauger = LOW;
bool infeedHopperFullState = LOW;

const int ulimitoutfeedPin = 11;
const int llimitoutfeedPin = 10;
const int outfeedaugerPin = 8;
const int outfeedHopperFullStatePin = 4;
int outfeedfaultsignal = 2;
bool outfeeduplimitState ;
bool outfeedlowlimitState ;
bool outfeedfaultSignal = LOW;
bool outfeedauger = LOW;
bool outfeedHopperFullState = LOW;
void setup()
{
  pinMode( ulimitinfeedPin, INPUT);
  pinMode(infeedaugerPin, OUTPUT);
  pinMode (llimitinfeedPin, INPUT);
  pinMode (infeedHopperFullStatePin, OUTPUT);
  pinMode (infeedfaultsignal, OUTPUT);

  pinMode( ulimitoutfeedPin, INPUT);
  pinMode(outfeedaugerPin, OUTPUT);
  pinMode (llimitoutfeedPin, INPUT);
  pinMode (outfeedHopperFullStatePin, OUTPUT);
  pinMode (outfeedfaultsignal, OUTPUT);
}


void loop() {
}
void infeedauger1 () {

  //read both limits at the start of the loop, then use the Status to do your control. ie, you take a snapshot of you project inputs.
  infeeduplimitState = digitalRead(ulimitinfeedPin);
  infeedlowlimitState = digitalRead(llimitinfeedPin);
  digitalWrite(infeedaugerPin, infeedauger);
  {}
  if (infeeduplimitState == LOW && infeedlowlimitState == LOW) //hopper is full.
  {
    infeedauger = LOW;
    infeedfaultSignal = LOW;
    infeedHopperFullState = HIGH;
  }
  {
    if (infeeduplimitState == HIGH && infeedlowlimitState == HIGH) //Hopper is empty.
    {
      infeedauger = HIGH;
      infeedfaultSignal = LOW;
      infeedHopperFullState = LOW;
    }
    {
      if (infeeduplimitState == HIGH && infeedlowlimitState == LOW & infeedHopperFullState == LOW) //Hopper is filling
      {
        infeedauger = HIGH;
        infeedfaultSignal = LOW;
      }
      {
        if (infeeduplimitState == LOW && infeedlowlimitState == HIGH)  //not a possible combination when operating correctly.
        {
          infeedauger = LOW;
          infeedfaultSignal = HIGH;
        }
      }

      void outfeedauger1 () {
      {
        //read both limits at the start of the loop, then use the Status to do your control. ie, you take a snapshot of you project inputs
        outfeeduplimitState = digitalRead(ulimitoutfeedPin);
        outfeedlowlimitState = digitalRead(llimitoutfeedPin);
        digitalWrite(outfeedaugerPin, outfeedauger);
        {

          if (outfeeduplimitState == LOW && outfeedlowlimitState == LOW) //hopper is full.
          {
            outfeedauger = LOW;
            outfeedfaultSignal = LOW;
            outfeedHopperFullState = HIGH;
          }
          if (outfeeduplimitState == HIGH && outfeedlowlimitState == HIGH) //Hopper is empty.
          {
            outfeedauger = HIGH;
            outfeedfaultSignal = LOW;
            outfeedHopperFullState = LOW;
          }
          if (outfeeduplimitState == HIGH && outfeedlowlimitState == LOW & outfeedHopperFullState == LOW) //Hopper is filling
          {
            outfeedauger = HIGH;
            outfeedfaultSignal = LOW;
          }
          if (outfeeduplimitState == LOW && outfeedlowlimitState == HIGH)  //not a possible combination when operating correctly.
          {
            outfeedauger = LOW;
            outfeedfaultSignal = HIGH;
          }
        }


outsider

Shouldn't line 80 be a " } " instead of " { " ?

saximus

The curly braces are still a giant mess. You probably need to go through it, group by group, to work out what you're trying to keep together and why.
You're also doing nothing in the loop at the moment. Is that deliberate or is it a symptom of the seemingly random curly bracket locations?

Go Up