So i got this program and it works fine. It is supposed to generate a pwm signal of a predetermined frequency by using a function.
The downside however is that i can only run this function on one pin at a time. How can i get it to start and finish on 2 pins simultaneously (for example pin 10 and 11)?
For my project i need 4 pins to run in pairs (with delays between the pairs)
void frecventa(byte targetPin, int highRate, int lowRate, int n)
/* targetPin=nr of pin used
highRate=High state duration
lowRate=Low state duration
n=number of repeats*/
{
for (int i=0; i < n; i++)
{
digitalWrite(targetPin, HIGH);
delay(highRate);
digitalWrite(targetPin, LOW);
delay(lowRate);
}
}
void setup() {
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
}
void loop() {
frecventa(9,16,16,70);
delay(2000);
frecventa(10,16,16,70);
delay(2000);
}