Dear Arduino Community!
First of all I would like to say "Hi!" to all of you!
Im new
to the arduino and microcontrollers in general but Im amazed
what even a designer with some programming skills can do with
it. ![]()
My question:
I would like to build my own class lib for fading leds but Im
not really sure what Im doing wrong.
This is my FadeLED.h:
#ifndef FadeLED_h
#define FadeLED_h
#include "WProgram.h"
class FadeLED
{
public:
  FadeLED(int ledPin,int fadeSpeed);
  void fade();
private:
  int pulseSignal();
  int _loga[64];
  int _pin;
  int _fadeSpeed;
  int _counter;
  int _changeMarker;
};
#endif
This is my FadeLED.cpp
#include "WProgram.h"
#include "FadeLED.h"
FadeLED::FadeLED(int pin, int fadeSpeed)
{
pinMode(pin, OUTPUT);
_pin = pin;
_fadeSpeed = fadeSpeed;
_counter = 0;
_changeMarker = 1;
_loga[64] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,16,18,20,22,25,28,30,33,36,39,42,46,49,53,56,60,64,68,72,77,81,6,90,95,100,105,110,116,121,127,132,138,144,150,156,163,169,176,182,189,196,203,210,218,225,233,240,248,255};
}
void FadeLED::fade()
{
int pwmSignal = pulseSignal();
analogWrite(_pin, pwmSignal);
delay(_fadeSpeed);
}
int FadeLED::pulseSignal()
{
 if(_counter == 63){
  _changeMarker = -1;
 }
 if(_counter == 0){
  _changeMarker = 1;
 }
 _counter = _counter+_changeMarker;
 int value = _loga[_counter];
 return value;
}
And this is my sketchfile:
#include <FadeLED.h>
FadeLED myLed(10,50);
void setup(){
Â
}
void loop(){
myLed.fade();
}
Basically I understand the concept of classes etc. but I
get allways the following error:
C:\Program Files\arduino-0022\libraries\FadeLED\FadeLED.cpp: In
constructor 'FadeLED::FadeLED(int, int)':
C:\Program Files\arduino-0022\libraries\FadeLED\FadeLED.cpp:11:
error: expected primary-expression before '{' token
C:\Program Files\arduino-0022\libraries\FadeLED\FadeLED.cpp:11:
error: expected `;' before '{' token
I dont see where a ";" is missing!? What could be wrong!? :\
Thank you very much for help! ![]()
Regards!