Arduino uno millis() funtion code problem

#include "funshield.h"

unsigned long startMillis;
unsigned long currentMillis;
const unsigned long period = 300;
const byte ledPin = 4;
int ledPin[] = { led1_pin, led2_pin, led3_pin, led4_pin };

void setup() {
    int i = 0
    for (int **i** = 0; i < 4; i++);
        pinMode(ledPin[i], OUTPUT);
    startMillis = millis();
}

void loop()
{
    currentMillis = millis();
    if (currentMillis - startMillis >= period)
        int i = 0;
    for (**i**; i > 4; i++) {
        digitalWrite(ledPin, !digitalRead(ledPin));
        digitalWrite(ledPin[i], LOW);
        digitalWrite(ledPin[i], HIGH);
        startMillis = currentMillis;
    }

    
    for (i = 4; i >= 0; i--) {
        digitalWrite(ledPin, !digitalRead(ledPin));
        digitalWrite(ledPin[i], LOW);
        digitalWrite(ledPin[i], HIGH);
        startMillis = currentMillis;
    }
}

i want know why even if I write int i =0 still show me i undefined identifier

void setup() {
    int i = 0
    for (int **i** = 0; i < 4; i++);
        pinMode(ledPin[i], OUTPUT);
    startMillis = millis();
}

Oops

where is problem?

On the right.

Also oops.

thank you very much

Try the Arduino/Tools/Auto Format tool, to see if the reformatted code matches the intended syntax. Often it will do something unexpected that highlights an error.

Where are these defined?

Even if your syntax were correct this is redundant. For an iterator only used in the for loop it is sufficient just to define it in the for loop spec.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.