Hi,
After many hours, I can't figure out how this works. a void works just fine, but the second I use int all hell breaks loose.
I have tried everything but for some reason I keep getting either
argument type of 'int (Instrumentation::)()'does not match 'int'
or
expected constructor, destructor, or type conversion before 'Instrumentation'
Please help, I'm sure you can return something from a class I just cant find/figure out how.
Here is my attempt:
Instrumentation.h file
/*
Instrumentation.h
*/
#ifndef Instrumentation_h
#define Instrumentation_h
#include "WProgram.h"
class Instrumentation
{
public:
Instrumentation();
~Instrumentation();
int BatteryVoltage();
private:
int Test;
};
#endif
Instrumentation.cpp file
/*
Instrumentation.cpp
*/
#include "WProgram.h"
#include "Instrumentation.h"
// Constructor
Instrumentation::Instrumentation()
(
// Constructor/Initializer
)
// Destructor
Instrumentation::~Instrumentation(){/*nothing to destruct*/}
int Instrumentation::BatteryVoltage
{
int intBatteryVoltage = analogRead(A1);
// Scale ADC value Here
return intBatteryVoltage;
}
Test.pde
#include "Instrumentation.h"
Instrumentation instrumentation;
void setup()
{
Serial.begin(9600);
Serial.println("Serial Util");
}
void loop() {
char InputChr;
// check if data has been sent from the computer:
//if (Serial.available()) {
// // read the most recent byte (which will be from 0 to 255):
// InputChr = Serial.read();
int Test = instrumentation.BatteryVoltage;
Serial.println(Test);
delay(3000);
}
BTW is it posible to have the code in the h file and cpp file in a single file?
Thanks