I've been using Arduino for a good while now, so I'm pretty familiar with the basics, but I've just started getting into the details of libraries, specifically writing my own libraries. As a test library, I created a basic blink library using the format given in the Morse tutorial here;
I created the cpp file first, and made it as simple as possible. Here it is;
/*
test library 1 cpp file
*/
#include "Arduino.h"
#include "test1.h"
test1::test1()
{
}
void test1::Blink() {
digitalWrite(13, 1);
delay(500);
digitalWrite(13, 0);
delay(500);
}
Then I made the h file;
/*
test library 1
*/
#ifndef test1_h
#define test1_h
#include "Arduino.h"
class test1
{
public:
test1();
void Blink();
private:
};
#endif
Finally I did the keyword file;
test1 KEYWORD1
Blink KEYWORD2
I can't find anything wrong with any of it, but it's probably something really simple and obvious. Anyway, I tried to use it with this code (after restarting the arduino environment of course);
#include <test1.h>
test1 test();
void setup() {
pinMode(13, OUTPUT);
}
void loop() {
test.Blink(13, 500, 10);
}
Unfortunately I keep getting this error;
test1library.ino: In function 'void loop()':
test1library:10: error: request for member 'Blink' in 'test', which is of non-class type 'test1()'
request for member 'Blink' in 'test', which is of non-class type 'test1()'
I'm not sure what this means and I certainly don't know how to fix it. Any suggestions or ideas would be greatly appreciated.
~Josh
update: final code is in the last reply