Hi, I'm a first time poster and haven't touched any type of programming in years. I'm hoping that I'm just missing something simple. I should note that the code is not originally mine and is being used by permission of the original creator, Mancave Effects. I cannot seem to find the TEA5767radio.h header in the Arduino IDE library so created a local copy of it. I get a "undefined reference to `TEA5767Radio::setFrequency(float)'" for all three instances of attempting to use a function declared in the header.
Header:
#include <Wire.h>
#ifndef TEA5767Radio_h
#define TEA5767Radio_h
class TEA5767Radio
{
private:
int _address;
public:
TEA5767Radio();
TEA5767Radio(int address);
void setFrequency(float frequency);
void setFrequency();
};
#endif
Program:
#include <TEA5767.h>
#include <TM1637Display.h>
#include <Wire.h>
#include "TEA5767Radio.h"
TEA5767Radio radio = TEA5767Radio();
int switchPin = 2; // Switch for tuning Up
int switchPin1 = 3; // Switch for tuning Random
int switchPin2 = 4; // Switch for tuning Down
int potPin = A2; // scan speed Potentiometer
int val = 0;
int senseLimit = 15; // raise this number to decrease sensitivity (up to 1023 max)
int probePin = A0; // analog 5
bool running = false;
const int CLK = 12; // Display clk
const int DIO = 11; // Display dio
long randNumber;
TM1637Display display(CLK, DIO);
void setup()
{
Serial.begin(9600);
pinMode(switchPin, INPUT); //defines switchpin as Input
digitalWrite(switchPin, HIGH);
pinMode(switchPin1, INPUT); //defines switchpin as Input
digitalWrite(switchPin1, HIGH);
pinMode(switchPin2, INPUT); //defines switchpin as Input
digitalWrite(switchPin2, HIGH);
unsigned char buf[5];
Wire.begin();
display.setBrightness(0x0a); //set the diplay to maximum brightness
randomSeed(analogRead(0));
}
void(* resetFunc) (void) = 0; //declare reset function @ address 0
void loop ()
{
if (digitalRead(switchPin1) == LOW)
{ randNumber = random(80.1, 110.1); //radio scans random number from freq. 80.1-110.1
radio.setFrequency(randNumber);
display.showNumberDec(randNumber, false);
val = analogRead(potPin); // read the value from the sensor
delay(val); // map potentiometer value to delay
if
(digitalRead(switchPin1) == HIGH) {
display.showNumberDec(0000);
resetFunc(); //reset arduino board
}
}
if (digitalRead(switchPin) == LOW)
for ( int i = 750 ; i < 1100 ; i++ ) {
float freq1 = i / 10.0 ;
radio.setFrequency(freq1);
display.showNumberDec(i);
val = analogRead(potPin); // read the value from the sensor
delay(val); // map potentiometer value to delay
if
(digitalRead(switchPin) == HIGH) {
display.showNumberDec(0000);
resetFunc(); //reset arduino board
}
}
if (digitalRead(switchPin2) == LOW)
{
for ( int i = 1100 ; i > 750 ; i-- ) {
float freq1 = i / 10.0 ;
radio.setFrequency(freq1);
display.showNumberDec(i);
val = analogRead(potPin);
delay(val);
if
(digitalRead(switchPin2) == HIGH) {
display.showNumberDec(0000);
resetFunc();
}}}}
Error:
C:\Users\kshir\AppData\Local\Temp\ccRxNzBc.ltrans0.ltrans.o: In function global constructors keyed to 65535_0_SpiritBox_Main.ino.cpp.o.3374': <artificial>:(.text.startup+0x78): undefined reference to TEA5767Radio::TEA5767Radio()'
C:\Users\kshir\AppData\Local\Temp\ccRxNzBc.ltrans0.ltrans.o: In function loop': C:\Users\kshir\Downloads\The Ultimate GD\The Ultimate GD\Arduino\SpiritBox_Main/SpiritBox_Main.ino:50: undefined reference to TEA5767Radio::setFrequency(float)'
C:\Users\kshir\Downloads\The Ultimate GD\The Ultimate GD\Arduino\SpiritBox_Main/SpiritBox_Main.ino:66: undefined reference to TEA5767Radio::setFrequency(float)' C:\Users\kshir\Downloads\The Ultimate GD\The Ultimate GD\Arduino\SpiritBox_Main/SpiritBox_Main.ino:80: undefined reference to TEA5767Radio::setFrequency(float)'
collect2.exe: error: ld returned 1 exit status
exit status 1
Compilation error: exit status 1
I appreciate any help I can get in resolving this error.
Thanks,
Kash