I was testing a code for the ultrasonic sensor for the uno rev3 example and this is the third time but the past two worked What am I doing wrong?``
Arduino:1.8.19 (Windows Store 1.8.57.0) (Windows 10), Scheda:"Arduino Uno"
C:\Users\ironm\OneDrive\Desktop\coding\Elegoo\Italiano\code\Lesson 10 Ultrasonic Sensor Module\SR04_Example\SR04_Example.ino: In function 'void setup()':
SR04_Example:25:6: error: redefinition of 'void setup()'
void setup()
^~~~~
C:\Users\ironm\OneDrive\Desktop\coding\Elegoo\Italiano\code\Lesson 10 Ultrasonic Sensor Module\SR04_Example\SR04_Example.ino:8:6: note: 'void setup()' previously defined here
void setup() {
^~~~~
C:\Users\ironm\OneDrive\Desktop\coding\Elegoo\Italiano\code\Lesson 10 Ultrasonic Sensor Module\SR04_Example\SR04_Example.ino: In function 'void loop()':
SR04_Example:32:6: error: redefinition of 'void loop()'
void loop()
^~~~
C:\Users\ironm\OneDrive\Desktop\coding\Elegoo\Italiano\code\Lesson 10 Ultrasonic Sensor Module\SR04_Example\SR04_Example.ino:13:6: note: 'void loop()' previously defined here
void loop() {
^~~~
exit status 1
redefinition of 'void setup()'
Questo report potrebbe essere più ricco di informazioni abilitando l'opzione
"Mostra un output dettagliato durante la compilazione"
in "File -> Impostazioni"
So you have a definition of the setup() function starting at line 25 of your sketch.
But that is not allowed because you also have a definition of that function starting at line 8:
You can only have one setup function in your sketch.
As for the fix, we will need to see your sketch in order to provide guidance. Please post your full sketch.
Select Tools > Auto Format from the Arduino IDE's menus. This will make it easier for you to spot bugs and make it easier for us to read.
Select Edit > Copy for Forum from the Arduino IDE's menus.
In a forum reply here, click on the post composer field.
Press Ctrl+V. This will paste the sketch to the post composer.
Move the cursor outside of the code tags before you add any additional text to your reply.
Repeat the above process if your sketch has multiple tabs.
Click the Reply button to post your reply.
When your code requires a library that's not included with the Arduino IDE please post a link to where you downloaded that library from or if you installed it using Library Manager (Sketch > Include Library > Manage Libraries in the Arduino IDE) then say so and state the full name of the library.