vendredi 19 juin 2020

What is an expected initializer before "if" statement? [closed]

In this program, I have 2 millis timers running, and for my first if statement

if (currentMillis - startMillis = period) //1st timer for button, test whether the period has elapsed

I keep getting an error that says I am missing an initializer beforehand. I checked my brackets to see if I was over or under including anything but I cannot find anything.

int ledPin = 13;
int lastButton;
int currentButton;
boolean ledOn = false;
int report;

unsigned long startMillis;  //some global variables available anywhere in the program
unsigned long currentMillis;
const unsigned long period = 1000;  //the value is a number of milliseconds
const unsigned long motortime = 1000; //motor time
unsigned long startmotor; //start time for motor

void setup()
{
  Serial.begin(9600);
  pinMode(switchPin, INPUT);
  pinMode(ledPin, OUTPUT);

  startMillis = millis();  //initial start time

  currentMillis = millis();  //get the current "time" (actually the number of milliseconds since the program started)
}

void loop()


if (currentMillis - startMillis = period)  //1st timer for button, test whether the period has elapsed
  { 
  currentButton = digitalRead(switchPin);
  Serial.print(currentButton);
  Serial.print(";");
  Serial.println(lastButton);

  if (ledOn == true && millis - start = motortime ) //checking to see if 2nd timer has passed the required time for motor

         {digitalWrite (ledPin, HIGH);
          ledOn == false;


       if (lastButton == 0 && currentButton == 1)
  {
    startMillis = millis();
    ledOn = !ledOn;
    startfeeder = millis();
   digitalWrite(ledPin, HIGH);
   if(ledOn == true)
    {
   }}}}}



Aucun commentaire:

Enregistrer un commentaire