I have a fairly simple program for an Arduino Nano, and I am using VS code with PlatformIO.
The first time I built it there was no problem, I made changes to main() and now on building i get output like this.
Building in release mode
Linking .pio/build/nanoatmega328/firmware.elf
.pio/build/nanoatmega328/src/main.cpp.o (symbol from plugin): In function `ts_1_end_us':
(.text+0x0): multiple definition of `ts_1_end_us'
.pio/build/nanoatmega328/src/Ver1_main.cpp.o (symbol from plugin):(.text+0x0): first defined here
.pio/build/nanoatmega328/src/main.cpp.o (symbol from plugin): In function `ts_1_end_us':
(.text+0x0): multiple definition of `speed_1_measured'
.pio/build/nanoatmega328/src/Ver1_main.cpp.o (symbol from plugin):(.text+0x0): first defined here
.pio/build/nanoatmega328/src/main.cpp.o (symbol from plugin): In function `ts_1_end_us':
(.text+0x0): multiple definition of `curtain_1_measured'
.pio/build/nanoatmega328/src/Ver1_main.cpp.o (symbol from plugin):(.text+0x0):
....... Multiple lines like this.
(.text+0x0): multiple definition of `setup'
.pio/build/nanoatmega328/src/Ver1_main.cpp.o (symbol from plugin):(.text+0x0): first defined here
collect2: error: ld returned 1 exit status
*** [.pio/build/nanoatmega328/firmware.elf] Error 1
==================================================================== [FAILED]
I seem to be doing something wrong, but what?
Edit.
I created a new main.cpp and renamed the old main.cpp to Ver1_main.cpp. The build process seems to be using both hence the duplications I guess (and it is only a guess). But how do I stop it using Ver1_main.cpp in the build if that is in fact the issue?
Edit of the edit.
I have sort of solved the issue by abandoning PlatformIO, renanimng the main.cpp file to main.ino and using the Arduino IDE, which just works. Its a shame to have to do this as PlatfomIO in VS code was recomended as the way to go. But “just works” wins out over multiple lines of errors, that I sort of understand but have no idea where to start to fix.