I'm a student, learning about MBEDs. I'm using Nucleo board and the MBED online compiler. Here's my code:
LM35.h
#ifndef MBED_LM35
#define MBED_LM35
#include "mbed.h"
class LM35
{
public:
LM35(PinName pin);
void mjerenje();
private:
AnalogIn _pin;
};
#endif
LM35.cpp
#include "LM35.h"
#include "mbed.h"
LM35::LM35(PinName pin) : _pin(pin) {}
float temperatura;
void LM35::mjerenje()
{
Serial pc(USBTX, USBRX);
temperatura = _pin.read();
temperatura = (temperatura*5000)/10;
pc.printf("Temperatura je %.2f stupnjeva Celzijevih.\n \r", temperatura);
return temperatura;
}
and here's Main.cpp
#include "mbed.h"
#include "LM35.h"
DigitalOut led1(PC_12);
Serial pc(USBTX, USBRX);
LM35 senzor(PC_0);
int main()
{
senzor.mjerenje();
float temperatura2 = LM35();
pc.printf("%f", temperatura2);
}
I'm having trouble with getting temperatura out of library and using it in main.cpp. I get following error: Error: No matching constructor for initialization of 'LM35' in "main.cpp", Line: 16, Col: 27
Can someone help me?
in LM35.cpp
void LM35::mjerenje()
return a float value, should be -->
float LM35::mjerenje()
in the main.cpp
float temperatura2;
temperatura2 = senzor.mjerenje();