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
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);
}
}
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.
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.