3

This is my first question! i'm sorry if i'm doing something wrong. I'm trying to write a code that blinks some leds, but i cant quite work out how to use structs as arguments.

This is the code:

void setup(){
  pinMode(2, OUTPUT);
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);
  //digitalWrite(2,HIGH); //debugging

}

struct Timer {
  unsigned long DutyCycle;
  unsigned long LastTime;
};


void SwitchPin(int pinn, bool ledstate,Timer timer) {
  if (millis() - timer.LastTime >= timer.DutyCycle) {
    if (ledstate == LOW) {
      ledstate = HIGH;
    } else {
      ledstate = LOW;
    }
    digitalWrite(pinn, ledstate);
  }
}

void loop()
{

}

When i try to verify it says:

exit status 1
'Timer' has not been declared

among other rubish. I'm very new to programming in general, so probably i'm doing something very wrong without noticing it. I would be very glad if you can explain exactly what im doing wrong, so i know what to do in the future.

0 Answers0