I am trying to make a library that controls a rgb led. so far i have:
#include "Arduino.h"
#include "RGBLed.h"
//Constructor again
RGBLed::RGBLed(int red, int green, int blue){
pinMode(red, OUTPUT);
pinMode(green, OUTPUT);
pinMode(blue, OUTPUT);
redPin = red;
greenPin = green;
bluePin = blue;
}
void RGBLed::setColor(int r,int g,int b){
analogWrite(redPin,r);
analogWrite(greenPin,g);
analogWrite(bluePin,b);
}
and
#ifndef RGBLed_h
#define RGBLed_h
#include "Arduino.h"
class RGBLed{
public:
//constructor
RGBLed(int red, int green, int blue);
//all the pins
int redPin;
int greenPin;
int bluePin;
//sets the color
void setColor(int r, int g, int b);
//returns the color value of each color
int redVal;
int greenVal;
int blueVal;
};
#endif
when i run this code:
#include <RGBLed.h>
RGBLed r(3,5,6);
void setup(){
}
void loop(){
}
i get the error:
Test_RGBLed:2: error: 'RGBLed' does not name a type
I know java, but i am new to c++. can anyone help?