As a new arduino user I’m actually learning about how to create a new library.
What I want is to create a General code that access the library and get a variable and it’s value defined inside the library by a class.
For example:
I created the header and source code files and also the class related to them as followed the codes below:
Header file:
#ifndef teste1_h
#define teste1_h
#if ARDUINO >= 100
#include “Arduino.h”
#else
#include “WProgram.h”
#include “pins_arduino.h”
#include “WConstants.h”
#endif
class DigitalPin
{
public:
int on(); //function
int on1; // variable defined
};
#endif
Source code:
#include “teste1.h”
int DigitalPin::on() // function
{
int on1=1;// could be any number
return on1; return variable
}
By using the general source I would access through the code below:
General code:
#include “teste1.h”
DigitalPin teste;
void setup()
{
Serial.begin(9600);
int test11 = 1;
}
void loop()
{
int test3;
test3 = teste.on(); // access the variable inside the library
Serial.println(test3);
delay(1000);
}
Any suggestions???