Redefinition of 'void setup()' Error

Hello I am fairly new to using arduino, I have been using a arduino Uno for this project. The main goal is to have one light fade in and out while the other blinks rapidly, but I keep encountering the error "redefinition of 'void setup()'" This is my code so far.

int led2 = 4;
int led = 2;
int brightness = 0;
int fadeAmount = 5;

void setup() {
pinMode(led, OUTPUT);
}

void loop() {
analogWrite(led, brightness);

brightness = brightness + fadeAmount;

if (brightness <= 0 || brightness >= 255) {
fadeAmount = -fadeAmount;
}
delay(30);
}
void setup() {
pinMode(led2, OUTPUT);
}

void loop() {
digitalWrite(led2, HIGH);
delay(500);
digitalWrite(led2, LOW);
delay(500);
}

You can only have one setup function and one loop function. You will need to merge the second set's code into the first ones and then delete the second.

Thank you.

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