Pages: [1]   Go Down
Author Topic: undefined refernce to loop  (Read 1894 times)
0 Members and 1 Guest are viewing this topic.
The bubble
Offline Offline
Newbie
*
Karma: 0
Posts: 18
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
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);
  }
}
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
void loop(int aimTemp, int aimPerc){

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

Code:
double getTemp(double Voltage){
What is the purpose of passing Voltage to this function, when it is never used?
Logged

The bubble
Offline Offline
Newbie
*
Karma: 0
Posts: 18
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
« Last Edit: July 26, 2010, 05:32:56 am by EmmyS7 » Logged

Manchester (England England)
Online Online
Brattain Member
*****
Karma: 602
Posts: 33381
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

The bubble
Offline Offline
Newbie
*
Karma: 0
Posts: 18
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

The bubble
Offline Offline
Newbie
*
Karma: 0
Posts: 18
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Cumming, GA
Offline Offline
Edison Member
*
Karma: 20
Posts: 1643
Ultimate DIY: Arduino
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Check Here: http://www.arduino.cc/playground/ComponentLib/Ps2mouse
Logged

Pages: [1]   Go Up
Jump to: