Advertisement
Guest User

Untitled

a guest
Jun 29th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.07 KB | None | 0 0
  1. int chan1 = 2;
  2. int chan2 = 3;
  3. int chan3 = 4;
  4. int chan4 = 7;  //channels 5 and 6 have known PWM sync issues
  5. int chan5 = 8;
  6. int chan6 = 9;
  7. int chan7 = 10;
  8.  
  9. int v1 = 255
  10. int v2 = 204
  11. int v3 = 102
  12.  
  13. //ADDED BY NOAM
  14. int vcurrent[12];
  15.  
  16. int tsecond = 1
  17. int skiv = 100 //reference potentiometer value in case no input is detected
  18. int skivPin = 2
  19.  
  20.  
  21. int pulseUp(ta, te, xch){ //PULSE FUNCTION UP; ta = pulse time anfang, te = pulse time ende, xch = channel
  22.   if (tsecond > ta && tsecond <= (ta + 25)) { //FADE UP
  23.         vcurrent[xch] = vcurrent[xch] + 2;
  24.   }
  25.   if (tsecond > (ta + 25) && tsecond <= (te - 25)) { //HOLD AT 255
  26.     vcurrent[xch] = v1;
  27.   }
  28.   if (tsecond > (te - 25) && tsecond <= (te)) { ??FADE DOWN
  29.     vcurrent[xch] = vcurrent[xch] - 2;  
  30.    }
  31.    pinMode(xch, vcurrent[xch]);
  32. }
  33.  
  34.  
  35.  
  36. //CHANGED BY NOAM
  37. int pulseDown(ta, te, xch){ //PULSE FUNCTION DOWN; ta = pulse time anfang, te = pulse time ende, xch = channel
  38.   if (tsecond > ta && tsecond <= (ta + 25)) {
  39.     vcurrent[xch] = vcurrent[xch] - 4;
  40.   }
  41.   if (tsecond > (ta + 25) && tsecond <= (te - 25)) {
  42.     vcurrent[xch] = v3;
  43.   }
  44.   if (tsecond > (te - 25) && tsecond <= (te)) {
  45.     vcurrent[xch] = vcurrent[xch] + 4;
  46.   }
  47.  
  48.   pinMode(xch, vcurrent[xch])
  49. }
  50.  
  51. void setup()
  52. {
  53.   pinMode(chan1, OUTPUT);  //sets all channels to PWM output
  54.   pinMode(chan2, OUTPUT);
  55.   pinMode(chan3, OUTPUT);
  56.   pinMode(chan4, OUTPUT);
  57.   pinMode(chan5, OUTPUT);
  58.   pinMode(chan6, OUTPUT);
  59.   pinMode(chan7, OUTPUT);
  60.   pinMode(skivPin, INPUT);
  61.   //ADDED BY NOAM
  62.   for (int i=0; i < 12; i++) vcurrent[i] = v2; //or whatever
  63. }
  64.  
  65. void loop()
  66. {
  67.   tsecond++; //maybe (tsecond++)*k where k is default to 1 with adjustment for pattern speed
  68.   if (tsecond > 1000) {
  69.     tsecond = 1; //resets pattern
  70.   }
  71.  
  72.  
  73.   chan1pattern(tsecond);
  74.   chan2pattern(tsecond);
  75.   chan3pattern(tsecond);
  76.   chan4pattern(tsecond);
  77.   chan5pattern(tsecond);
  78.   chan6pattern(tsecond);
  79.   chan7pattern(tsecond);
  80.   skiv = analogRead(skivPin); //reads potentiometer value
  81.   delay(skiv); //sets delay to potentiometer value
  82. }
  83.  
  84. // WRITE PATTERNS IN
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement