Liamlambchop
- Sep 19, 2011
- 14
- Joined
- Sep 19, 2011
- Messages
- 14
Hey everyone,
I am trying to use an Arduino library called 'Timer1' http://arduino.cc/playground/Code/Timer1
I am trying to use it to switch on a pulse width modulation function every x microseconds. I am doing this, instead of simply running the PWM function in the loop, because I need to run other things in the loop
Here is my sketch in English, could I have some help with the C language?
if Timer1 period is up {
begin PWM function;
stop Timer1;
start a new timer which will be used to stop the PWM function;
{
if the new timer's period is up {
stop PWM;
restart old Timer1 (and hence restart the cycle);}
}
}
This would have to be in my void loop() I'd imagine. And I would also likely have to be using Timer1.read().... but I am not sure how to implement that.
Any help would be greatly appreciated!
I am trying to use an Arduino library called 'Timer1' http://arduino.cc/playground/Code/Timer1
I am trying to use it to switch on a pulse width modulation function every x microseconds. I am doing this, instead of simply running the PWM function in the loop, because I need to run other things in the loop
Here is my sketch in English, could I have some help with the C language?
if Timer1 period is up {
begin PWM function;
stop Timer1;
start a new timer which will be used to stop the PWM function;
{
if the new timer's period is up {
stop PWM;
restart old Timer1 (and hence restart the cycle);}
}
}
This would have to be in my void loop() I'd imagine. And I would also likely have to be using Timer1.read().... but I am not sure how to implement that.
Any help would be greatly appreciated!