Timer 1 Arduino - Create 2 Timers I’m trying to output 2 separate frequencies using 2 output pins from an Arduino using the Timer 1 library. A snippet of the code is show below.   

void setup() 
{
 Serial.begin(9600);
 pinMode(button,INPUT_PULLUP);
 pinMode(button2,INPUT_PULLUP);
 pinMode(sig_out, OUTPUT);
 pinMode(sig_out2, OUTPUT);
Timer1.initialize(1000);
Timer1.pwm(sig_out,512,period);
Timer1.pwm(sig_out2,512,period2); 
}


The issue is the way I’ve wrote this makes sense as I’ve initialised 2 outputs and 2 inputs but the ‘period’ is getting overwritten as there’s 1 timer and I’m not sure how to stop this. I was thinking about storing them in variables (like 'T1=' 'T2=') but it would still use the same timer.

I just wanted to know if there’s a way to use 2 timers so the Arduino outputs the frequencies separately.
The Timer1 library only supports... Timer&nbsp;1! So you only have one
hardware timer available. If you are using an Arduino Uno or anything
similar, you have a couple of other timers. However, unlike
Timer&nbsp;1, which is a 16-bit timer, the others are 8-bit only. This
means they are very limited in the range and precision of the
frequencies they can generate. If you have an Arduino Mega, then you
have a few other 16-bit timers available. You may want to search for a
library called Timer3, which should work just like Timer1, while using
the 16-bit Timer&nbsp;3.

If you don't find any suitable library, you may still be able to
generate your two signals using only Timer&nbsp;1. Here is the trick:


set both PWM outputs to “toggle on compare match”
enable both compare match interrupts
in each of these ISRs, advance the compare match register by half a
period of the corresponding signal.


For doing this you will need to dig into the low-level details of how a
timer actually works. I recommend you start by reading the
Timers and counters tutorial by Nick Gammon.
Take the time to read and
study this. It's not a topic you will be able to master in just a
couple of hours.