Every sketch brings up an error

I'm trying to get a micro servo to run off the Arduino Uno and I've wired it up without a breadboard because I didn't have one to hand.

But every time I try to load the sketch from the library I get an error code....
'Arduino: 1.8.20 Hourly Build 2022/04/25 09:33 (Windows 10), Board: "Arduino Uno"

C:\Users\happy\OneDrive\Documents\Arduino\sketch_jun02a\code_for_project_1.ino: In function 'void setup()':

code_for_project_1:10:6: error: redefinition of 'void setup()'

void setup() {

  ^~~~~

C:\Users\happy\OneDrive\Documents\Arduino\sketch_jun02a\sketch_jun02a.ino:10:6: note: 'void setup()' previously defined here

void setup() {

  ^~~~~

C:\Users\happy\OneDrive\Documents\Arduino\sketch_jun02a\code_for_project_1.ino: In function 'void loop()':

code_for_project_1:14:6: error: redefinition of 'void loop()'

void loop() {

  ^~~~

C:\Users\happy\OneDrive\Documents\Arduino\sketch_jun02a\sketch_jun02a.ino:15:6: note: 'void loop()' previously defined here

void loop() {

  ^~~~

C:\Users\happy\OneDrive\Documents\Arduino\sketch_jun02a\code_for_project_2.ino: In function 'void setup()':

code_for_project_2:5:6: error: redefinition of 'void setup()'

void setup() {

  ^~~~~

C:\Users\happy\OneDrive\Documents\Arduino\sketch_jun02a\sketch_jun02a.ino:10:6: note: 'void setup()' previously defined here

void setup() {

  ^~~~~

C:\Users\happy\OneDrive\Documents\Arduino\sketch_jun02a\code_for_project_2.ino: In function 'void loop()':

code_for_project_2:9:6: error: redefinition of 'void loop()'

void loop() {

  ^~~~

C:\Users\happy\OneDrive\Documents\Arduino\sketch_jun02a\sketch_jun02a.ino:15:6: note: 'void loop()' previously defined here

void loop() {

  ^~~~

exit status 1

redefinition of 'void setup()'

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.'

surely if the sketch is already in the library it shouldn't have an error, well you'd think so wouldn't you.

I'm sure I'm doing something wrong here. So if anyone knows what this error means I'd be glad to hear about it.

Thanks a lot.

Have you tried uploading the simple blink sketch?

What happens to that.

You should not be running the hourly build, you should be running the latest stable release.

How many file tabs have you got in the IDE ?

You have two .ino files in one sketch. They each have a setup() function and a loop() function.

Delete the "code_for_project_1.ino" file that got saved in Arduino\sketch_jun02a

Hi John
All sorted. Once I downloaded the correct Arduino Package (I was using the nightly one) I initiated the 'Blink' sketch and now I have an LED that's happily blinking at me. I've even changed the delay down to 500 to get the LED to blink faster.

I'm really chuffed that it's working as it should. Now on to get a Micro Servo to go forward and backward via Bluetooth.

Thanks a lot for your help.

Michael

1 Like

Hi Grumpy Mike.
That makes two of us, I'm not alone in the world, after all,

Downloaded the right program as I was using the 'Nightly' edition and uploaded the Blink sketch to the board and now have a red LED blinking away like mad. I'm glad I got it sorted as I have loads of add-ons to try different things with this board. Now I'll get to work developing my own sketches to do other things.

I'm very grateful for your help.

Michael

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