ERROR: multiple definition of `__vector_14'

Hi, im working on a project from school, its a final test, and it has to be turned in a week. So im writing a code and I keep geting this error message:
proto.cpp.o (symbol from plugin): In function conf_bots()': (.text+0x0): multiple definition of __vector_14'
.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

#include <Arduino.h>
#include "proto.h"

void set_display(void); //función para setear números a los displays (0-9999) fila 2

int main(){

in_out(); 
conf_timer0();
set_display();
numbers();

sei(); 

}


ISR(TIMER0_COMPA_vect){

}

void set_display(void){
numbers();
conf_bots();
uint8_t numero[10]= {B00111111, B00000110, B01011011, B01001111, B01100110, B01101101, B01111101, B00000111, B01111111, B01100111 };  
int caso=0;

if(!bot1){
caso++;
}
PORTB = (PORTB & B11111100) | (numero[caso] & B00000011); // enmascaro los bits que quiero usar del Puerto B
PORTD = (PORTD & B00000011) | (numero[caso] & B11111100); // enmascaro los bits que quiero usar del Puerto D



}

then i have a library where its supposed to be the error, but when I compile it, its succesful

#include "Arduino.h"

#define bot1 ((PINC >> PC0) & 1) // macros para pulsadores

#define bot2 ((PINC >> PC1) & 1)

#define bot3 ((PINC >> PC2) & 1)

#define bot4 ((PINC >> PC3) & 1)

#define bot5 ((PINC >> PC4) & 1)

#define bot6 ((PINC >> PC5) & 1)

#define ida 0

#define vuelta 1

void conf_timer0(void);

void conf_bots(void);

void tp5(void);

void IN_OUT(void); // función para las entradas y salidas

void in_out(void); //función para entradas y salidas de la integradora

void numbers(void); //función para descomponer el número que queramos en unidad, decena, centena y miles
#include "proto.h"

int caso = 0, dir = 0, on_off = 0;                                                      // caso del vector, dirección en la que va, variable para el encendido y apagado
uint8_t prevbot1, prevbot2, prevbot3, prevbot4, prevbot5, prevbot6, statbot1, statbot2, statbot3, 
statbot4, statbot5, statbot6; // estados de los botones y estados previos
uint16_t vel = 300;                                                                     // variable para ajustar la velocidad al presionar los pulsadores 2, 3 y 4



//-----------------------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------------------

void conf_bots(void) // configuración de botones, antirrebotes, detección de flanco
{
    uint16_t ctbot1 = 0, ctsec = 0, ctbot2 = 0, ctbot3 = 0, ctbot4 = 0, ctbot5=0, ctbot6=0;
    ctsec++;
    if (bot1 == 0)
    { // si el bot está pulsado
        if (ctbot1 < 255)
        {
            ctbot1++;
        } // si el cont vale menos que 255, aumentamos su valor
    }
    else
    {
        ctbot1 = 0; // si no está pulsado, el cont vale 0
    }
    if (ctbot1 > 10)
    {                 // si desde que toqué el botón pasaron 10ms
        statbot1 = 1; // el estado del boton es 1
    }
    else
    {
        statbot1 = 0; // sino el estado del boton es 0
    }
    //-----------------------------------------------------------------------------------------------

if(bot2==0){ //si el bot está pulsado
if(ctbot2<255){ctbot2++; } //si el cont vale menos que 255, aumentamos su valor
}
else{
  ctbot2=0; //si no está pulsado, el cont vale 0

}
if(ctbot2>10){  //si desde que toqué el botón pasaron 10ms
  statbot2=1; //el estado del boton es 1
}else{
  statbot2=0; //sino el estado del boton es 0 
 }

//----------------------------------

if(bot3==0){ //si el bot está pulsado
if(ctbot3<255){ctbot3++; } //si el cont vale menos que 255, aumentamos su valor
}
else{
  ctbot3=0; //si no está pulsado, el cont vale 0

}
if(ctbot3>10){  //si desde que toqué el botón pasaron 10ms
  statbot3=1; //el estado del boton es 1
}else{
  statbot3=0; //sino el estado del boton es 0 
}

//--------------------

if(bot4==0){ //si el bot está pulsado
if(ctbot4<255){ctbot4++; } //si el cont vale menos que 255, aumentamos su valor
}
else{
  ctbot4=0; //si no está pulsado, el cont vale 0
}
if(ctbot4>10){  //si desde que toqué el botón pasaron 10ms
  statbot4=1; //el estado del boton es 1
}else{
  statbot4=0; //sino el estado del boton es 0 
}

//----------------------------------------------------------------------------------------

if(bot5==0){ //si el bot está pulsado
if(ctbot5<255){ctbot5++; } //si el cont vale menos que 255, aumentamos su valor
}
else{
  ctbot5=0; //si no está pulsado, el cont vale 0

}
if(ctbot5>10){  //si desde que toqué el botón pasaron 10ms
  statbot5=1; //el estado del boton es 1
}else{
  statbot5=0; //sino el estado del boton es 0 
}

//--------------------

if(bot6==0){ //si el bot está pulsado
if(ctbot6<255){ctbot6++; } //si el cont vale menos que 255, aumentamos su valor
}
else{
  ctbot6=0; //si no está pulsado, el cont vale 0
}
if(ctbot6>10){  //si desde que toqué el botón pasaron 10ms
  statbot6=1; //el estado del boton es 1
}else{
  statbot6=0; //sino el estado del boton es 0
}
}
//-----------------------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------------------
void tp5(void)
{


    {
        int16_t sec[9] = {B00000001, B00000011, B00000110, B00001100, B00011000, B00110000, B01100000, B11000000, B10000000}; // vector para la secuencia

        IN_OUT(); // invoco las funciones que creé
        conf_timer0();

        while (1)
        {

            if (prevbot1 == 0 && statbot1 == 1) // si el pulsador estaba suelto y ahora está pulsado (detección de flanco)
            {
                on_off = ~on_off; // invertimos todos los bits de on_off
            }
            prevbot1 = statbot1; // actualizamos el estado del botón
            // _delay_ms(2);

            if (on_off != 0)
            {
                PORTD = (PORTD & B00000011) | (sec[caso] & B11111100); // enmascaramos los bits que no queremos configurar
                PORTB = (PORTB & B11111100) | (sec[caso] & B00000011); // ^^^^^^^^^^^^^^
            }
            else
            {
                PORTB &= ~((1 < PB0) | (1 << PB1)); // sino, apagamos los leds
                PORTD &= ~((1 << PD2) | (1 << PD3) | (1 << PD4) | (1 << PD5) | (1 << PD6) | (1 << PD7));
                caso = 0; // para que comience desde 0 cuando volvamos a presionar el bot1
            }
            _delay_ms(2);
            // sin este delay, el while(1) se ejecuta más rápido que la interrupción, por lo que no funcionará
        }
    }
}
//-----------------------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------------------
void IN_OUT(void) // creo función para entradas y salidas
{
    DDRC &= ~((1 << PC0) | (1 << PC1) | (1 << PC2) | (1 << PC3));                          // configuro las entradas del PORTC (pulsadores)
    PORTC |= ((1 << PC0) | (1 << PC1) | (1 << PC2) | (1 << PC3));                          // configuro pull ups internas de los pulsadores
    DDRB |= ((1 << PB0) | (1 << PB1));                                                     // configuro salidas del PORTB (leds)
    DDRD |= ((1 << PD2) | (1 << PD3) | (1 << PD4) | (1 << PD5) | (1 << PD6) | (1 << PD7)); // configuro salidas del PORTD (leds)
}
//-----------------------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------------------
void conf_timer0(void) // función para configurar el timer0
{
    TCCR0A |= (1 << WGM01);              // modo CTC
    TCCR0B |= (1 << CS01) | (1 << CS00); // prescaler 64
    OCR0A = 249;                         // valor de comparación para 1ms
    TIMSK0 |= (1 << OCIE0A);             // habilitar interrupción para el contador A
    sei();                               // habilitar interrupciones globales
}

//-----------------------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------------------

ISR(TIMER0_COMPA_vect)
{
    static uint16_t ctbot1 = 0, ctsec = 0, ctbot2 = 0, ctbot3 = 0, ctbot4 = 0;
    ctsec++;
    if (bot1 == 0)
    { // si el bot está pulsado
        if (ctbot1 < 255)
        {
            ctbot1++;
        } // si el cont vale menos que 255, aumentamos su valor
    }
    else
    {
        ctbot1 = 0; // si no está pulsado, el cont vale 0
    }
    if (ctbot1 > 10)
    {                 // si desde que toqué el botón pasaron 10ms
        statbot1 = 1; // el estado del boton es 1
    }
    else
    {
        statbot1 = 0; // sino el estado del boton es 0
    }

    //-------------------------------------------

    if (dir == ida) // si dirección es igual a ida (0)
    {
        if (ctsec > vel) // si contsec es mayor a velocidad
        {
            caso++;
            ctsec = 0; // se aumenta el valor del caso y contsec vuelve a 0
        }
        if (caso > 7) // si el caso es mayor 7
        {
            dir = 1; // dirección vale 1, entonces irá en reversa
        }
    }
    else // si dirección es 1
    {
        if (ctsec > vel)
        { // si es mayor a velocidad
            caso--;
            ctsec = 0; // se resta valor de caso, y contsec vuelve a 0
        }
        if (caso < 0) // si caso menor a 0
        {
            dir = 0; // dirección vuelve a 0 para que vuelva a ir en dirección original
        }
    }

    //--------------------------------------------------------------

    if (!bot2 && !bot3)
    { // si el bot2 y el bot3 están apretados, baja la velocidad
        vel -= 5;
        ctsec -= 1;
    }

    if (!bot2 && !bot4)
    { // si el bot2  y el bot4 están apretados, sube la velocidad
        vel += 5;
        ctsec += 1;
    }

    if (vel < 10)
    { // barrera para que la secuencia siempre siga viendose y no pare
        vel = 10;
    }
    if (vel > 600)
    { // si supera este valor, volverá a valer 0 en algún momento, no queremos que eso suceda
        vel = 600;
    }

    //-----------------------------------

    if (bot2 == 0)
    { // si el bot está pulsado
        if (ctbot2 < 255)
        {
            ctbot2++;
        } // si el cont vale menos que 255, aumentamos su valor
    }
    else
    {
        ctbot2 = 0; // si no está pulsado, el cont vale 0
    }
    if (ctbot2 > 10)
    {                 // si desde que toqué el botón pasaron 10ms
        statbot2 = 1; // el estado del boton es 1
    }
    else
    {
        statbot2 = 0; // sino el estado del boton es 0
    }
    //----------------------------------

    if (bot3 == 0)
    { // si el bot está pulsado
        if (ctbot3 < 255)
        {
            ctbot3++;
        } // si el cont vale menos que 255, aumentamos su valor
    }
    else
    {
        ctbot3 = 0; // si no está pulsado, el cont vale 0
    }
    if (ctbot3 > 10)
    {                 // si desde que toqué el botón pasaron 10ms
        statbot3 = 1; // el estado del boton es 1
    }
    else
    {
        statbot3 = 0; // sino el estado del boton es 0
    }
    //--------------------

    if (bot4 == 0)
    { // si el bot está pulsado
        if (ctbot4 < 255)
        {
            ctbot4++;
        } // si el cont vale menos que 255, aumentamos su valor
    }
    else
    {
        ctbot4 = 0; // si no está pulsado, el cont vale 0
    }
    if (ctbot4 > 10)
    {                 // si desde que toqué el botón pasaron 10ms
        statbot4 = 1; // el estado del boton es 1
    }
    else
    {
        statbot4 = 0; // sino el estado del boton es 0
    }
}

//-----------------------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------------------

void in_out(void){ //in and out de la integradora AED 5to
DDRC &= ~((1 << PC0) | (1 << PC1) | (1 << PC2) | (1 << PC3) | (1 << PC4) | (1 << PC5)); //entrada, pulsadores
DDRB |= ((1 << PB0) | (1 << PB1) | (1 << PB4) | (1 << PB5)); //salida, leds y displays
DDRD |= ((1 << PD2) | (1 << PD3) | (1 << PD4) | (1 << PD5) | (1 << PD6)); //salida, displays

}

//-----------------------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------------------

void numbers(void){
uint16_t miles=0; 
uint8_t unidad=0, decena=0, centena=0;
uint8_t numero[10] = {B00111111, B00000110, B01011011, B01001111, B01100110, B01101101, B01111101, B00000111, B01111111, B01100111 }; 
// numeros del 0-9 en el display de 7 segmentos. numero fijo a mostrar

//descomponemos el número en unidad, decena, centena y miles  
unidad= numero[10] % 10;
decena= (numero[10] / 10) % 10;
centena = ( numero[10] / 100) % 10;
miles = ( numero[10] / 1000) % 10;


}

The error indicates that the variable or function is defined in at least two places, and the compiler doesn’t know which one to use. It’s defined here: .pio\build\uno\src\main.cpp.o. You need to locate the second definition.

You can use your text editor to search through all the included files to find where the duplicate definition exists. Alternatively, you can comment out the conflicting definition and, in the setup() function, add this line:

Serial.print(__vector_14);

Run the code to verify that it outputs the correct value. This will help you ensure that the issue is resolved. If it is not you will have to find the other instance of it.

its a function where you use the TIMER 0 in CTC mode, its a function from the arduino uno. The thing is that i didnt write any code in it, because i wasnt using it yet.

ohhhh, thanks, i just found it. I really aprecciate it

1 Like

The way you used code tags resulted in a mess. I've (partially fixed) it. The three back ticks (```) need to be on their own line.

You are welcome, a big thanks for letting us know. Have a great week!

Did the issue resolved now? If so, please add a "Solution" mark to the most useful answer.

arduino uno

You have marked your topic as solved. Do you still need help?

Your code in #1 has two of these:

and

If you fixed it, you probably deleted one of them.

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