Can't upload code to Arduino Uno

I just can’t seem to upload my code. Whenever I try I get this error code:

Processing uno (platform: atmelavr; board: uno; framework: arduino)
-----------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/atmelavr/uno.html
PLATFORM: Atmel AVR (5.0.0) > Arduino Uno
HARDWARE: ATMEGA328P 16MHz, 2KB RAM, 31.50KB Flash
DEBUG: Current (avr-stub) External (avr-stub, simavr)
PACKAGES: 
 - framework-arduino-avr @ 5.2.0 
 - tool-avrdude @ 1.60300.200527 (6.3.0) 
 - toolchain-atmelavr @ 1.70300.191015 (7.3.0)
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 6 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Linking .pio/build/uno/firmware.elf
.pio/build/uno/src/Blink.cpp.o (symbol from plugin): In function `setup':
(.text+0x0): multiple definition of `setup'
.pio/build/uno/src/AlternatingLights.cpp.o (symbol from plugin):(.text+0x0): first defined here
.pio/build/uno/src/Blink.cpp.o (symbol from plugin): In function `setup':
(.text+0x0): multiple definition of `loop'
.pio/build/uno/src/AlternatingLights.cpp.o (symbol from plugin):(.text+0x0): first defined here
.pio/build/uno/src/BlinkSerial.cpp.o (symbol from plugin): In function `setup':
(.text+0x0): multiple definition of `setup'
.pio/build/uno/src/AlternatingLights.cpp.o (symbol from plugin):(.text+0x0): first defined here
.pio/build/uno/src/BlinkSerial.cpp.o (symbol from plugin): In function `setup':
(.text+0x0): multiple definition of `loop'
.pio/build/uno/src/AlternatingLights.cpp.o (symbol from plugin):(.text+0x0): first defined here
.pio/build/uno/src/SerialLedSwitch.cpp.o (symbol from plugin): In function `setup':
(.text+0x0): multiple definition of `setup'
.pio/build/uno/src/AlternatingLights.cpp.o (symbol from plugin):(.text+0x0): first defined here
.pio/build/uno/src/SerialLedSwitch.cpp.o (symbol from plugin): In function `setup':
(.text+0x0): multiple definition of `loop'
.pio/build/uno/src/AlternatingLights.cpp.o (symbol from plugin):(.text+0x0): first defined here
.pio/build/uno/src/SingleBlink.cpp.o (symbol from plugin): In function `setup':
(.text+0x0): multiple definition of `setup'
.pio/build/uno/src/AlternatingLights.cpp.o (symbol from plugin):(.text+0x0): first defined here
.pio/build/uno/src/SingleBlink.cpp.o (symbol from plugin): In function `setup':
(.text+0x0): multiple definition of `loop'
.pio/build/uno/src/AlternatingLights.cpp.o (symbol from plugin):(.text+0x0): first defined here
collect2: error: ld returned 1 exit status
*** [.pio/build/uno/firmware.elf] Error 1
======================================= [FAILED] Took 0.80 seconds =======================================

 *  The terminal process "platformio 'run', '--target', 'upload', '--environment', 'uno', '--upload-port', '/dev/cu.usbmodem101'" terminated with exit code: 1. 
 *  Terminal will be reused by tasks, press any key to close it.

Please help!

Hi @clemesbot1

For better readability I edited your post and used pre-formatted text for code and log sections.

The error message says:

You have multiple setup() and multiple loop() functions in multiple .cpp files in your project, namely

  • Blink.cpp
  • AlternatingLights.cpp
  • BlinkSerial.cpp
  • SerialLedSwitch.cpp
  • SingleBlink.cpp

This is invalid.
You can just have one setup() and one loop() function in one .cpp file.

Usually you have a main.cpp where setup() loop() and loop are implemented.

Wait, but they are different codes in different files. I need multiple so that all the codes work. I need to make a new folder for each new file?

Are this different projects?

Then you need to create different projects. One for each file.

1 Like