Creating a new library (new user)


as new arduino user i'm learning how create new library.
what want create general code access library , variable , it's value defined inside library class.

for example:
i created header , source code files , class related them followed 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;// number
  return on1; return variable
}

by using general source access through 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 variable inside library
serial.println(test3);
delay(1000);
}

any suggestions???

goodbye.


Arduino Forum > Using Arduino > Programming Questions > Creating a new library (new user)


arduino

Comments

Popular posts from this blog

DHT11 Time out error using v0.4.1library

Sketch upload fails with Java error (___REMOVE___/bin/avrdude)!

Arduino Uno + KTY81/210 temperature sensor