error: redefinition of 'void setup()

Whenever I try to use any of the sample code I find in the playground, I get an error when I try to compile the code. Here it is:

In function 'void setup()':
error: redefinition of 'void setup()' In function 'void loop()':

What am I doing wrong?

I am currently trying to use the code for a piezo player from this link:

1 Like

Do you have two tabs in your sketch? When you drag things into the environment, it adds it to the current sketch when you may want to simply open it.

4 Likes

This can be common. An assumption is that tabs are for new sketches. But they only open another file for some more code; for the same sketch. Meaning you only declare void setup() and void loop() once.

So you may have declared this more than once leading to this error.

7 Likes

I try compiling it and everything was fine?
Patgadget
Montreal