Library help

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?

Your library is in the wrong directory.

how could i fix this?

Your library belongs in the {Sketchbook}/libraries/RGBLed/ directory. Move the header file and source file there.

thanks all for the help!

RGBLed::RGBLed(int red, int green, int blue)
{
	pinMode(red, OUTPUT);
	pinMode(green, OUTPUT);
	pinMode(blue, OUTPUT);
	
	redPin = red;
	greenPin = green;
	bluePin = blue;
}

Do you have any idea when your constructor is called with respect to when the init() function has been called, and activated all the hardware?

I didn't think so. You should not be making assumptions about the status of the hardware in your constructor. Specifically, you should NOT be calling pinMode() in the constructor.

You SHOULD have a begin() method that does the hardware-related stuff that you would normally put in the constructor, and you should call that method only after init() has been called.

How do you know when that is? Well, setup() is called AFTER init(), so calling the begin() methods in setup() is a good idea.

That is if you want your class to work properly.

Shouldn't this

#include "Arduino.h"

be instead

#include <Arduino.h>

?