Dancing Fountain Code repeated error : redefinition of void setup ()

I was helping my friend with some code for a dancing fountain but it … broke ?

The code has worked before , we have read many forums saying that you can only have one setup and loop which is what we did. its supposed to turn on and off different pumps in a dancing fountain , simple stuff , but i dont know where we went wrong. please help , we are using a arduino uno ? i think. (im a materials science major not CS unfortunately)

ERROR MESSAGE :

Arduino: 1.8.12 (Windows 10), Board: “Arduino Uno”

C:\Users\apowe\Videos\Desktop\Dancing_Fountain\The_ecstacy_of_gold__fountain_chero_\Dancng_Fountain\Dancng_Fountain.ino: In function ‘void setup()’:

Dancng_Fountain:7:6: error: redefinition of ‘void setup()’

void setup() { //continuously loop the program

^~~~~

C:\Users\apowe\Videos\Desktop\Dancing_Fountain\The_ecstacy_of_gold__fountain_chero_\Dancng_Fountain\Dancng_Fountain.ino:1:6: note: ‘void setup()’ previously defined here

void setup() { // initialize digital pin 1,2,3 as an output.

^~~~~

C:\Users\apowe\Videos\Desktop\Dancing_Fountain\The_ecstacy_of_gold__fountain_chero_\Dancng_Fountain\Simple_gifts__fountain_chero_.ino: In function ‘void setup()’:

Simple_gifts__fountain_chero_:1:6: error: redefinition of ‘void setup()’

void setup() { // initialize digital pin 1,2,3 as an output.

^~~~~

C:\Users\apowe\Videos\Desktop\Dancing_Fountain\The_ecstacy_of_gold__fountain_chero_\Dancng_Fountain\Dancng_Fountain.ino:1:6: note: ‘void setup()’ previously defined here

void setup() { // initialize digital pin 1,2,3 as an output.

^~~~~

C:\Users\apowe\Videos\Desktop\Dancing_Fountain\The_ecstacy_of_gold__fountain_chero_\Dancng_Fountain\Simple_gifts__fountain_chero_.ino: In function ‘void setup()’:

Simple_gifts__fountain_chero_:7:6: error: redefinition of ‘void setup()’

void setup() { //continuously loop the program

^~~~~

C:\Users\apowe\Videos\Desktop\Dancing_Fountain\The_ecstacy_of_gold__fountain_chero_\Dancng_Fountain\Dancng_Fountain.ino:1:6: note: ‘void setup()’ previously defined here

void setup() { // initialize digital pin 1,2,3 as an output.

^~~~~

C:\Users\apowe\Videos\Desktop\Dancing_Fountain\The_ecstacy_of_gold__fountain_chero_\Dancng_Fountain\Squib cakes.ino: In function ‘void setup()’:

C:\Users\apowe\Videos\Desktop\Dancing_Fountain\The_ecstacy_of_gold__fountain_chero_\Dancng_Fountain\Squib cakes.ino:1:6: error: redefinition of ‘void setup()’

void setup() { // initialize digital pin 1,2,3 as an output.

^~~~~

C:\Users\apowe\Videos\Desktop\Dancing_Fountain\The_ecstacy_of_gold__fountain_chero_\Dancng_Fountain\Dancng_Fountain.ino:1:6: note: ‘void setup()’ previously defined here

void setup() { // initialize digital pin 1,2,3 as an output.

^~~~~

C:\Users\apowe\Videos\Desktop\Dancing_Fountain\The_ecstacy_of_gold__fountain_chero_\Dancng_Fountain\The_ecstacy_of_gold__fountain_chero_.ino: In function ‘void setup()’:

The_ecstacy_of_gold__fountain_chero_:1:6: error: redefinition of ‘void setup()’

void setup() { // initialize digital pin 1,2,3 as an output.

^~~~~

C:\Users\apowe\Videos\Desktop\Dancing_Fountain\The_ecstacy_of_gold__fountain_chero_\Dancng_Fountain\Dancng_Fountain.ino:1:6: note: ‘void setup()’ previously defined here

void setup() { // initialize digital pin 1,2,3 as an output.

^~~~~

C:\Users\apowe\Videos\Desktop\Dancing_Fountain\The_ecstacy_of_gold__fountain_chero_\Dancng_Fountain\The_ecstacy_of_gold__fountain_chero_.ino: In function ‘void loop()’:

The_ecstacy_of_gold__fountain_chero_:7:6: error: redefinition of ‘void loop()’

void loop() { //continuously loop the program

^~~~

C:\Users\apowe\Videos\Desktop\Dancing_Fountain\The_ecstacy_of_gold__fountain_chero_\Dancng_Fountain\Squib cakes.ino:7:6: note: ‘void loop()’ previously defined here

void loop() { //continuously loop the program

^~~~

exit status 1
redefinition of ‘void setup()’

This report would have more information with
“Show verbose output during compilation”
option enabled in File → Preferences.

The_ecstacy_of_gold__fountain_chero_.ino (1.76 KB)

void setup() {    // initialize digital pin 1,2,3 as an output.
  pinMode(1, OUTPUT);
  pinMode(2, OUTPUT);
  pinMode(3, OUTPUT);
}


void loop() {             //continuously loop the program
  digitalWrite(1, HIGH);   //Turn pins 1,2&3 on & off in sequnce for two rounds
  delay(0);
  digitalWrite(1, LOW);
  delay(23880);
  digitalWrite(2, HIGH);
  delay(500);
  digitalWrite(2, LOW);
  delay(22770);
  digitalWrite(2, HIGH);
  delay(22130);
  digitalWrite(3, LOW);
  delay(0);
  digitalWrite(1, HIGH);
  delay(15560);
  digitalWrite(1, LOW);
  delay(0);
  digitalWrite(2, HIGH);
  delay(21650);
  digitalWrite(2, LOW);
  delay(1732);
  digitalWrite(3, HIGH);
  delay(1990);
  digitalWrite(3, LOW);
  digitalWrite(1, HIGH);   //Flash pin 1 (Blue LED) 4 times
  delay(25180);
  digitalWrite(2, LOW);
  delay(0);
  digitalWrite(2, HIGH);
  delay(2360);
  digitalWrite(1, LOW);
  delay(0);
  digitalWrite(2, HIGH);
  delay(2620);
  digitalWrite(1, LOW);
  delay(0);
  digitalWrite(1, HIGH);
  delay(24060);
  digitalWrite(1, LOW);
  delay(0);
  digitalWrite(2, HIGH);   //Flash pin 2 (yellow LED) 4 times
  delay(2430);
  digitalWrite(2, LOW);
  delay(500);
  digitalWrite(2, HIGH);
  delay(500);
  digitalWrite(3, LOW);
  delay(500);
  digitalWrite(3, HIGH);
  delay(500);
  digitalWrite(1, LOW);
  delay(500);
  digitalWrite(1, HIGH);
  delay(500);
  digitalWrite(2, LOW);
  delay(500);
  digitalWrite(3, HIGH);   //Flash pin 3 (Red LED) 4 times
  delay(0);
  digitalWrite(3, LOW);
  delay(500);
  digitalWrite(3, HIGH);
  delay(0);
  digitalWrite(2, LOW);
  delay(500);
  digitalWrite(2, HIGH);
  delay(500);
  digitalWrite(1, LOW);
  delay(0);
  digitalWrite(1, HIGH);
  delay(500);
  digitalWrite(3, LOW);
  delay(0);
}

Compiles okay for me with IDE 1.8.12

You have two separate programs in the same sketch:

C:\Users\apowe\Videos\Desktop\Dancing_Fountain\The_ecstacy_of_gold__fountain_chero_\Dancng_Fountain
|_ Dancng_Fountain.ino
|_ Simple_gifts__fountain_chero_.ino

In the Arduino IDE, you will see these as two tabs, the leftmost titled "Dancng_Fountain", the next titled "Simple_gifts__fountain_chero_".

Because sketches often only have a single .ino file, it's easy to come to the conclusion that the .ino file is the sketch. however, this is not true. It's the folder that's the sketch (in this case C:\Users\apowe\Videos\Desktop\Dancing_Fountain\The_ecstacy_of_gold__fountain_chero_\Dancng_Fountain). All source files in that folder will be compiled. So when you have two files, each with it's own separate program in the same sketch folder, you get these "error: redefinition of ..." errors.

The solution is to close the Arduino IDE and then move this file:

C:\Users\apowe\Videos\Desktop\Dancing_Fountain\The_ecstacy_of_gold__fountain_chero_\Dancng_Fountain\Simple_gifts__fountain_chero_.ino

to its own folder, which matches the name of the .ino file:

C:\Users\apowe\Videos\Desktop\Dancing_Fountain\The_ecstacy_of_gold__fountain_chero_\Simple_gifts__fountain_chero_\Simple_gifts__fountain_chero_.ino

After that, the "error: redefinition of ..." errors will no longer occur.