Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int chan1 = 2;
- int chan2 = 3;
- int chan3 = 4;
- int chan4 = 7; //channels 5 and 6 have known PWM sync issues
- int chan5 = 8;
- int chan6 = 9;
- int chan7 = 10;
- int v1 = 255
- int v2 = 204
- int v3 = 102
- //ADDED BY NOAM
- int vcurrent[12];
- int tsecond = 1
- int skiv = 100 //reference potentiometer value in case no input is detected
- int skivPin = 2
- int pulseUp(ta, te, xch){ //PULSE FUNCTION UP; ta = pulse time anfang, te = pulse time ende, xch = channel
- if (tsecond > ta && tsecond <= (ta + 25)) { //FADE UP
- vcurrent[xch] = vcurrent[xch] + 2;
- }
- if (tsecond > (ta + 25) && tsecond <= (te - 25)) { //HOLD AT 255
- vcurrent[xch] = v1;
- }
- if (tsecond > (te - 25) && tsecond <= (te)) { ??FADE DOWN
- vcurrent[xch] = vcurrent[xch] - 2;
- }
- pinMode(xch, vcurrent[xch]);
- }
- //CHANGED BY NOAM
- int pulseDown(ta, te, xch){ //PULSE FUNCTION DOWN; ta = pulse time anfang, te = pulse time ende, xch = channel
- if (tsecond > ta && tsecond <= (ta + 25)) {
- vcurrent[xch] = vcurrent[xch] - 4;
- }
- if (tsecond > (ta + 25) && tsecond <= (te - 25)) {
- vcurrent[xch] = v3;
- }
- if (tsecond > (te - 25) && tsecond <= (te)) {
- vcurrent[xch] = vcurrent[xch] + 4;
- }
- pinMode(xch, vcurrent[xch])
- }
- void setup()
- {
- pinMode(chan1, OUTPUT); //sets all channels to PWM output
- pinMode(chan2, OUTPUT);
- pinMode(chan3, OUTPUT);
- pinMode(chan4, OUTPUT);
- pinMode(chan5, OUTPUT);
- pinMode(chan6, OUTPUT);
- pinMode(chan7, OUTPUT);
- pinMode(skivPin, INPUT);
- //ADDED BY NOAM
- for (int i=0; i < 12; i++) vcurrent[i] = v2; //or whatever
- }
- void loop()
- {
- tsecond++; //maybe (tsecond++)*k where k is default to 1 with adjustment for pattern speed
- if (tsecond > 1000) {
- tsecond = 1; //resets pattern
- }
- chan1pattern(tsecond);
- chan2pattern(tsecond);
- chan3pattern(tsecond);
- chan4pattern(tsecond);
- chan5pattern(tsecond);
- chan6pattern(tsecond);
- chan7pattern(tsecond);
- skiv = analogRead(skivPin); //reads potentiometer value
- delay(skiv); //sets delay to potentiometer value
- }
- // WRITE PATTERNS IN
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement