Go Down

Topic: mstimer2 not working (Read 5248 times) previous topic - next topic

johnwasser

Everything you put in a program creates a 'slight delay'.  In this case the delay should be only a few microseconds (millionths of a second) so it should not cause a usability problem.
Send Bitcoin tips to: 1G2qoGwMRXx8az71DVP1E81jShxtbSh5Hp

Rupertt

Hello,

thnx to your help i nearly finished the sequnecer and now started finalizing my looper and I run into
the same problem.
I have 8 channels, each channel loops one note and gets triggert every few seconds.
When the note is retriggert i want the LED to flash, as long as the note is playing the LED should stay lit.
Most of the code is the same, only the function looks a bit different, could I use the mstimer here?
I tried but with the same result, note is playing but no LED is on.
Code: [Select]
void loopstep(int stepnr) {
 
if (currentSwitchState[stepnr] == 1) {
 
          AnalogValue[stepnr] = analogRead(stepnr);
          note[stepnr] = AnalogValue[stepnr]/8;
          noteOn(channel[stepnr], 0x7B, 0x00);
          noteOn(channel[stepnr], 64, 127);
          noteOn(channel2[stepnr], note[stepnr], 0x7F);
          lastNotePlayed[stepnr] = note[stepnr];
          lastSwitchState[stepnr] = 1;
         
          digitalWrite(LEDpins[stepnr], LOW);
          delay(30);         
          digitalWrite(LEDpins[stepnr], HIGH);
}
   if (currentSwitchState[stepnr] == 0 && lastSwitchState[stepnr] == 1) {
        noteOn(channel[stepnr], 0x7B, 0x00);
        //blink(1);
        digitalWrite(LEDpins[stepnr], LOW);
        lastSwitchState[stepnr] = 0;
    }
}


Go Up