Hi.
I’m about to programing a library for a RTD temp sensor.
I have done a sketch that working an now I want to implant it into a library. I’ve read a lot of exemple a many syntax, and non of them seem to work.
I’m very newbie on programing, I don’t understand haft of what I do. but my need are very simple. the library compile correctely but
I,m not able to make it do in a sketch. all I want to understand is the correct syntax to take a reading of an int, do my void library, and set an int of the output value.
this is my header and cpp file and an exemple of what I’ve try so far.
thank.
#ifndef RTD10kB3950_h
#define RTD10kB3950_h
#include “Arduino.h”
class RTD
{
public:
RTD(int Rt);
RTD(double temp);
void RTDraw();
private:
int _Rt;
double _temp;
};
#endif
#include “Arduino.h”
#include “RTD10kB3950.h”
RTD::RTD(int Rt){
//Rt=0;
_Rt = Rt;
}
RTD::RTD(double temp) {
temp = _temp;
}
int linearray = 0;
double RTDarray={
200, 149.78,
250, 139.91,
300, 132.19,
350, 125.88,
400, 120.58,
450, 116.01,
500, 112.02,
//… array is very long, I resume it
144650, -24.99,
144700, -25,
1000000, -50,
};
void RTD::RTDraw() {
while( _Rt > linearray[RTDarray]){
linearray++;
}
if (_Rt <= linearray[RTDarray]){
linearray++;
if ( (linearray[RTDarray] - _Rt) <= ((linearray-2[RTDarray])-_Rt)) {
_temp = linearray[RTDarray];
}
else {_temp = linearray-2[RTDarray];
}
linearray=0;
}
}
#include <RTD10kB3950.h>
int input = 10000;
double output = 0;
double temp;
void setup() {
Serial.begin(9600);
analogReadResolution(12);
}
void loop() {
RTD(Rt) = input;
RTD RTDraw();
output = temp;
Serial.println(output);
delay (1000);
}