Basically I want one LED to flash 5 times in the same amount of time it takes another LED to flash 4 times. This is what I have, but they are flashing independently and I need them to flash simultaneously.
//Making a 5/4 Polyrhythm with 2 LEDs
const int LED13 = 13;
const int LED7 = 7;
int i = 5;
void setup() {
pinMode(LED13, OUTPUT);
pinMode(LED7, OUTPUT);
}
void loop() {
for(i=0; i<5; i++)
{
digitalWrite (LED13, HIGH);
delay(500);
digitalWrite (LED13, LOW);
delay(800);
}
for(i=0; i<4; i++)
{
digitalWrite (LED7, HIGH);
delay(500);
digitalWrite (LED7, LOW);
delay(1000);
}
}
least common multipleand acting, or not, on each output as appropriate. Likely this means you will need an event happening at 20 times the desired repeition rate, which (if you intend the flashes to be visible as such to a human), is not even remotely difficult for an Arduino to handle. One LED would flash on events 0, 4, 8, 12, and 16, and the other one events 0, 5, 10, and 15... – Chris Stratton Dec 11 '15 at 01:56