Hello I have a problem with running TLC5940 functions within my own library
They work perfectly fine when i run them in my main.cpp file like this:
#include <Arduino.h>
#include <Tlc5940.h>
void setup(){
Tlc.init();
}
void loop(){
Tlc.set(4,2000);
Tlc.update();
}
But they don't react when i do it in my own library:
main.cpp
#include <Arduino.h>
#include "MyLibrary.h"
MyLibrary example = MyLibrary();
void setup() {
Serial.begin(9600);
}
void loop() {
example.turnLedOn(4);
}
MyLibrary.h
#ifndef MyLibrary_h
#define MyLibrary_h
#include "Arduino.h"
class MyLibrary {
public:
MyLibrary();
void turnLedOn(int);
private:
void setup();
};
#endif
MyLibrary.cpp
#include "Arduino.h"
#include "MyLibrary.h"
#include <Tlc5940.h>
//CONSTRUCTOR
MyLibrary::MyLibrary(){
setup();
}
boolean info = true;
void MyLibrary::setup(){
Serial.begin(9600);
Tlc.init();
Serial.println("Tlc was initialized");
}
void MyLibrary::turnLedOn(int pin){
while(1) {
Tlc.set(pin,2000);
Tlc.update();
if(info) {
Serial.println("I'm in the loop");
info = false;
}
}
}
This way all serial monitor communicates appear as expected, no compilation errors. However the diode is turned off.
I really care about putting this within a lib (code above is just an example, my code is kinda bigger than this), so if you guys have any idea why this isn't working plesase help me out, cannot hide that I'm new to arduino.
Cheers.