Thursday, August 20, 2009

HL1606: Separated timing and rate, rate based on potentiometer

See, better code.

 Posting the whole thing is a bit of a bear, I'm not loving the ePaper option, I will come up with something else but for now the important changes to the subroutines, rateModulo is the variable set by the analog sensor in the main loop.
void twoBits() {  int l;  for (l=0; l< 8; l++) {   //add a check kill switch   doNote(twoBitNoteArray[l], twoBitTimeArray[l], millis());  }  // just a little extra white space at the end in case it isn't followed  // by a clearStrip();  doNote(0,300, millis()); }   void doNote (byte colorNum, int duration, long startTime) {  int d;  int r;  int mCheck = 0;    byte color = colorArray[colorNum];  long endTime = startTime + (long) duration;  // release whitespace eats into the previous note!!!!!!!!  while (millis() < (endTime-release)) { //add a check_kill_switch   mCheck = micros() % rateModulo;   if (mCheck==0) {   //Serial.println(mCheck);   mystrip.pushCmd(color);   mystrip.latch();   }  }    while (millis() < endTime) { //add a check_kill_switch   mCheck = micros() % rateModulo;   if (mCheck==0) { mystrip.pushCmd(colorArray[0]);   mystrip.latch();   }  } }  

Download now or watch on posterous
MVI_4515.AVI (7187 KB)

Posted via email from what2day's posterous

No comments: