Go Down

Topic: undefined refernce to loop (Read 2100 times) previous topic - next topic

Ems7

I'm programming the board to run a process that turns a heater on, and off again depending on the voltage it receives in input, I've encountered a few straight forward errors, typos missing brackets etc but now i have this error.


C:\DOCUME~1\melanie\LOCALS~1\Temp\build5095839521417917747.tmp\core.a(main.cpp.o): In function `main':

C:\Documents and Settings\melanie\Desktop\arduino\arduino-0018\arduino-0018\hardware\arduino\cores\arduino/main.cpp:10: undefined reference to `loop'

my code is asfollows
Code: [Select]
int sensorPin = 0; // select input pin for thermocoupler
int heaterPin = 13; // selct output pin for heater
int sensorValue = 0; //variable to store value from sensor
int aimTemp=50;
int aimPerc= 10;
void setup(){
 // declare heaterPin as output
 pinMode(heaterPin, OUTPUT);
 pinMode(sensorPin, INPUT);
Serial.begin(9600); // connect to the serial port
}
double getTemp(double Voltage){
 // calculate the Temperature from the intput voltage
 // read out analogue value and plug it into your function to
 // calculate the Temperature
 double anVal = analogRead(sensorPin);
 return (anVal+0.0205)/0.0411;
}
void loop(int aimTemp, int aimPerc){
Serial.begin(9600);  
 // read the value of the sensor
 double anVal = analogRead(sensorPin);
 double Temperature= getTemp(anVal);
 Serial.print(anVal);

 if (Temperature>=aimTemp+aimTemp*aimPerc*0.01){
   //switch off
   digitalWrite (heaterPin, LOW);
 }
 if (Temperature<=aimTemp-aimTemp*aimPerc*0.01){
   //switch on
   digitalWrite (heaterPin, HIGH);
 }
 if ((Temperature>aimTemp-aimTemp*aimPerc*0.01) && (Temperature<aimTemp+aimTemp*aimPerc*0.01)){
   // switch on
   digitalWrite (heaterPin, HIGH);
 }
}

PaulS

Code: [Select]
void loop(int aimTemp, int aimPerc){


Say what? The loop function does not have any arguments.

Code: [Select]
double getTemp(double Voltage){

What is the purpose of passing Voltage to this function, when it is never used?

Ems7

#2
Jul 26, 2010, 12:30 pm Last Edit: Jul 26, 2010, 12:32 pm by EmmyS7 Reason: 1
I'm not sure, I didn't write this bit, my boss did, the voltage part is the input value, anaVal.

by deleting the bit between the brackets, ie the int aimtemp etc

Grumpy_Mike

Quote
I didn't write this bit, my boss did,


Sounds like you should ask your boss then.

However if he is thinking that loop() is like main() then perhaps he is thinking you can pass arguments into the program from command line options.

Ems7

Sorted it now, do you know if its possible to interface my board with a computer keyboard so that if i pressed y it preformed a function and if i pressed n it preformed another, eg on and off. I have the functions written and tested, but i'll like to control them with my computer.

PaulS

Quote
do you know if its possible to interface my board with a computer keyboard so that if i pressed y it preformed a function and if i pressed n it preformed another, eg on and off.

Yes, it is. Now, I suppose you want to know how.

Well, there needs to be some application listening on the PC that reads the key presses, and sends them to the serial port.

Then, there needs to be some code on the Arduino that looks for serial data (Serial.available()) and reads it (Serial.read()) if there is any data to read.

Then, it's just a matter of calling the right function based on the data read.

Ems7

Thankyou paulS, sorry for the silly newbie questions i've been thrown in the deep end with programming but i'm slowly getting there.


Go Up