Hi all,
I have a program i am developing that as is runs perfect or it does until i just decided to use the tone() function.
My board is Mega 2560 and I notice in the tone() programming reference guide it says...
Use of the tone() function will interfere with PWM output on pins 3 and 11 (on boards other than the Mega)
My output pins are 8 to 13 and I am using analogueWrite(pin,value)
Outputs 9 and 13 are worst affected, but this is a Mega and i should not suffer this bug no?
So digging around I think this is related to timers?
I don't really want to post all my code but giving that I am using the capSense library, PWM and tone all together I guess I'm pushing the internal timers to good workout.
I did see some code but now lost about resetting timers?
Have I got a faulty board?
should the bug exist?
How can I cure / workaround?
Another way to make sound?
but this is a Mega and i should not suffer this bug no?
Wrong. The tone() function needs a timer. PWM needs timers. When you steal a timer for tone(), PWM has to go (on some pins).
So digging around I think this is related to timers?
PaulS - can you clear something up for me? I am having trouble reconciling your statements with the Arduino programming reference, and the specs of the two boards.
Use of the tone() function will interfere with PWM output on pins 3 and 11 (on boards other than the Mega).
According to the Arduino store, the Mega and Mega2560 both use the same chip - How can tone() take out two PWM pins on the Mega 2560 but not take out those pins on the Mega, if they both use the same chip? What is different?
According to the Arduino store, the Mega and Mega2560 both use the same chip - How can tone() take out two PWM pins on the Mega 2560 but not take out those pins on the Mega, if they both use the same chip? What is different?
There is only one Mega - with the 2560 chip. Using tone() takes a timer. The timer that it takes controls PWM on some pins on the Mega. Which pins depends on which timer tome use ON THE MEGA(2560).