I am playing with patterns at the moment and have the patterns running from my IR remote. The patterns and the IR are working spot on. But the issue I am having is that I have to let the whole pattern run to it's tenth pass before I can tun the pattern attached to button 2.
How to I make it so when I press Button 2 it will stop whatever Button 1 is doing and run the pattern for button 2?
This is prob a simple question for some but as a newbie it's mind numbing! XD
I have only posted a partial bit of the code as I dont think the whole code is needed for this question?
void loop()
{
if (irrecv.decode(&results)) {
lReceived = results.value ;
Serial.println(results.value);
switch (lReceived) {
// BUTTON 1
case button1:
for (int i=0; i <= 10; i++){
makePattern(Mouth, pattern1, 6);
makePattern(Mouth, pattern2, 6);
makePattern(Mouth, pattern3, 6);
makePattern(Mouth, pattern4, 6);
makePattern(Mouth, pattern5, 6);
makePattern(Mouth, pattern6, 6);
makePattern(Mouth, pattern7, 6);
makePattern(Mouth, pattern8, 6);
makePattern(Mouth, pattern9, 6);
makePattern(Mouth, pattern10, 6);
makePattern(Mouth, pattern11, 6);
makePattern(Mouth, pattern12, 6);
}
break;
{
// BUTTON 2
case button2:
for (int i=0; i <= 10; i++){
makePattern(Mouth, pattern13, 6);
makePattern(Mouth, pattern14, 6);
makePattern(Mouth, pattern15, 6);
makePattern(Mouth, pattern16, 6);
makePattern(Mouth, pattern17, 6);
makePattern(Mouth, pattern18, 6);
makePattern(Mouth, pattern19, 6);
}
break;
}
}
irrecv.resume(); // Receive the next value
}
}
void makePattern(int leds[], int pattern[], int num)
{
int delayTime = 100;
for(int i = 0; i < num; i++)
{
digitalWrite(leds[i], pattern[i]);
}
delay(delayTime);
}