Testing is a rabbit hole I’d rather save for later. I really only want the code to run. I’ve never had a program compile and upload successfully without actually working or doing something. But I just want to make it work.
I’ve done this before. I’ve stripped everything out and built it back piecemeal until I found the error. But once again I see something in PIO that doesn’t make sense. This is the whole program now:
//Ingeimaks #include <Arduino.h>
//definiamo i servomotori orizzontale e verticale
//Pin fotoresistenze
int ldrtopl = 2; //top left
int ldrtopr = 1; //top right
int ldrbotl = 3; // bottom left
int ldrbotr = 0; // bottom right
void setup ()
{
Serial.begin(9600);
delay(500);
}
void loop()
{
}
Here are the errors:
Linking .pio\build\uno\firmware.elf
.pio\build\uno\src\main1.cpp.o (symbol from plugin): In function setup': (.text+0x0): multiple definition of setup’
.pio\build\uno\src\main.cpp.o (symbol from plugin):(.text+0x0): first
defined here
.pio\build\uno\src\main1.cpp.o (symbol from plugin): In function setup': (.text+0x0): multiple definition of loop’
.pio\build\uno\src\main.cpp.o (symbol from plugin):(.text+0x0): first
defined here
.pio\build\uno\src\main1.cpp.o (symbol from plugin): In function setup': (.text+0x0): multiple definition of ldrbotr’
.pio\build\uno\src\main.cpp.o (symbol from plugin):(.text+0x0): first
defined here
.pio\build\uno\src\main1.cpp.o (symbol from plugin): In function setup': (.text+0x0): multiple definition of ldrbotl’
.pio\build\uno\src\main.cpp.o (symbol from plugin):(.text+0x0): first
defined here
.pio\build\uno\src\main1.cpp.o (symbol from plugin): In function setup': (.text+0x0): multiple definition of ldrtopr’
.pio\build\uno\src\main.cpp.o (symbol from plugin):(.text+0x0): first
defined here
.pio\build\uno\src\main1.cpp.o (symbol from plugin): In function setup': (.text+0x0): multiple definition of ldrtopl’
.pio\build\uno\src\main.cpp.o (symbol from plugin):(.text+0x0): first
defined here
collect2.exe: error: ld returned 1 exit status
*** [.pio\build\uno\firmware.elf] Error 1
==================== [FAILED]
To create (define) the code that defines the setup and loop functions. In a nutshell (although I haven’t tested this), you should be able to create a main.cpp in your /test folder (since unit testing uses this folder, not the main source folder), and
will get it past the error (because setup and loop are now defined), but will clearly do nothing at all. This is where the rest of the example code linked above comes in.
There is little point in using Test unless you are going to implement unit testing properly - i.e. automated code testing, automatic upload to device to test code on the actual hardware, etc. It’s not ‘test’ as in ‘have I put together valid code’ but test as in ‘try to compile and run this code, and check it responds to pre-programmed input the way it should’. ‘Build’ is the normal test of if the code will compile (and hopefully run).
If you are using PlatformIO chekc if you have your code placed on root with all the folders needed(include,src,lib,test) or you have selected the new paths in the compiler parameters