I'm new to C++ and Arduino libraries, so I have no clue what's wrong here. I'm making a library to drive a bicolour LED, based on some Processing code I wrote.
Here's the code:
BiColorLed.h
#ifndef BiColorLED
#define BiColorLED 1
#include "WProgram.h"
class BiColorLED{
public:
BiColorLED(uint8_t ledPin1, uint8_t ledPin2);
void drive();
void setColor(uint8_t toColor);
private:
uint8_t color;
uint8_t pin1, pin2;
bool yellowRed;
};
#endif
BiColorLed.cpp
#include "BiColorLED.h"
BiColorLED::BiColorLED(uint8_t ledPin1, uint8_t ledPin2) {
pin1=ledPin1;
pin2=ledPin2;
color=0;
yellowRed=false;
}
void setColor(uint8_t toColor) {
color=toColor;
drive(); // Change the color
}
void drive() {
// TODO blinking goes here
if (color == 3) { // Yellow
color = (yellowRed?1:2);
yellowRed = !yellowRed;
} // Beyond this point the color is always red, green, or black
// Actual LED driving
if (color == 1) { // Red
digitalWrite(pin1, HIGH);
digitalWrite(pin2, LOW);
} else if (color == 2) { // Green
digitalWrite(pin1, LOW);
digitalWrite(pin2, HIGH);
} else { // Black
digitalWrite(pin1, LOW);
digitalWrite(pin2, LOW);
}
}
And, just for completeness, my sketch:
#include <BiColorLED.h>
void setup() {}
void loop() {}
The .h and .cpp files are largely based off of looking at other libraries. Now, here's the problem: when I verify the sketch, the Arduino IDE comes back with:
In file included from BareMinimum.cpp:1:0:
/home/wolf/sketchbook/libraries/BiColorLED/BiColorLED.h:6:7: error: expected identifier before numeric constant
/home/wolf/sketchbook/libraries/BiColorLED/BiColorLED.h:6:7: error: expected unqualified-id before numeric constant
As near as I can tell, this means that there's a problem between the words class' and BiColorLED'. This line is copied verbatim from another library with a change of class name, so I can't figure out what's wrong. Any ideas?