-
Notifications
You must be signed in to change notification settings - Fork 0
/
LEDOrderedDimmer.h
40 lines (35 loc) · 927 Bytes
/
LEDOrderedDimmer.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include "LED.h"
class LEDOrderedDimmer {
public:
LEDOrderedDimmer(int _potPin, int _objectCounterMax){
objectCounter = 0;
if (_objectCounterMax > 50){
_objectCounterMax = 50;
}
objectCounterMax = _objectCounterMax;
ledContainer = new LED[objectCounterMax];
potPin = _potPin;
}
~LEDOrderedDimmer()
{
// cleanup of objects:
delete [] ledContainer;
}
void addLED(int pin, int orderedPos){
if (objectCounter < objectCounterMax){
ledContainer[objectCounter++].setPinPos(pin, orderedPos);
}
}
void updateLED(){
int brightness = map(analogRead(potPin), 0, 1023, 0, 5115);
for (int i = 0; i <= objectCounter; i++){
ledContainer[i].updateBrightness(brightness);
delay(10);
}
}
private:
LED *ledContainer;
int potPin;
int objectCounter;
int objectCounterMax;
};