Temperature sensor library errors
temp.h: #ifndef temp_h
#define temp_h
#include <arduino.h>
class temp {
public:
temp();
~temp();
void tmp(string u, int x);
};
#endif
temp.cpp: #include "temp.h"
}
//<<destructor>>
temp::~temp()
void temp::tmp(string u, int x){
int sv = analogread(x);
if (u == "f") {
float tmpf = (((sv * 5 / 1024) - 0.5) * 100) * 1.8 + 32;
}
if (u == "c") {
float tmpc = (((sv * 5 / 1024) - 0.5) * 100);
}
if (u == "k") {
float tmpk = (((sv * 5 / 1024) - 0.5) * 100) + 273.15;
}
if ( u == "f") {
return tmpf;
}
if ( u == "c") {
return tmpc;
}
if ( u == "k") {
return tmpk;
}
}
keywords.txt: temp keyword1
tmp keyword2
error message: arduino: 1.8.3 (windows xp), board: "arduino/genuino uno"
c:\documents , settings\mbryant\my documents\arduino\sketch_aug05b\sketch_aug05b.ino: in function 'void loop()':
sketch_aug05b:10: error: 'f' not declared in scope
serial.println(tmp(f, 3));
^
sketch_aug05b:10: error: 'tmp' not declared in scope
serial.println(tmp(f, 3));
^
exit status 1
'f' not declared in scope
this report have more information with
"show verbose output during compilation"
option enabled in file -> preferences.
main code: #include <temp.h>
void setup() {
// put setup code here, run once:
serial.begin(9600);
}
void loop() {
serial.println(tmp(f, 3));
}
sorry, rushed, new libraries, can me fix this?
#define temp_h
#include <arduino.h>
class temp {
public:
temp();
~temp();
void tmp(string u, int x);
};
#endif
temp.cpp: #include "temp.h"
}
//<<destructor>>
temp::~temp()
void temp::tmp(string u, int x){
int sv = analogread(x);
if (u == "f") {
float tmpf = (((sv * 5 / 1024) - 0.5) * 100) * 1.8 + 32;
}
if (u == "c") {
float tmpc = (((sv * 5 / 1024) - 0.5) * 100);
}
if (u == "k") {
float tmpk = (((sv * 5 / 1024) - 0.5) * 100) + 273.15;
}
if ( u == "f") {
return tmpf;
}
if ( u == "c") {
return tmpc;
}
if ( u == "k") {
return tmpk;
}
}
keywords.txt: temp keyword1
tmp keyword2
error message: arduino: 1.8.3 (windows xp), board: "arduino/genuino uno"
c:\documents , settings\mbryant\my documents\arduino\sketch_aug05b\sketch_aug05b.ino: in function 'void loop()':
sketch_aug05b:10: error: 'f' not declared in scope
serial.println(tmp(f, 3));
^
sketch_aug05b:10: error: 'tmp' not declared in scope
serial.println(tmp(f, 3));
^
exit status 1
'f' not declared in scope
this report have more information with
"show verbose output during compilation"
option enabled in file -> preferences.
main code: #include <temp.h>
void setup() {
// put setup code here, run once:
serial.begin(9600);
}
void loop() {
serial.println(tmp(f, 3));
}
sorry, rushed, new libraries, can me fix this?
this rushed,evidently.
you might explain think problem is, , intentions are.
Arduino Forum > Using Arduino > Programming Questions > Temperature sensor library errors
arduino
Comments
Post a Comment