09-27-2011 03:35 PM
I built a circuit like this - tricolor LED is controlled by the outputs 6,5,3 (PWM) and illuminates the photoresistor (analog input 1). Voltage on the photoresistor-resistor divider (analog input pin1) controls the frequency of a buzzer (output pin 8). I do not know why, but the output 3 stopped working as PWM. When I change blue color (pin 3) from 0 to 254 it gives the output voltage of 0V, and 255 gives 5V. Removing the buzzer from the block diagram restores normal functionality of the PWM ... Why?
One guy suggest that ATemega 328 has only 3 independent timers. If each PWM is implemented to counter this will create problem with the use of the buzzer which runs on PWM output too. So maybe buzzer is mapped to one of these PWM-timers?
If ATemega 328 has 3 timers and 6 PWM channels I understand that each of the channels can not be independent - am I right?
Arduino Labview toolkit suggest for PWM pins 3,5,6, so I suspect that I do not have the access to the remaining 3 PWM, have I?
10-01-2011 10:39 PM
Hey,
This is indeed a timer conflict. When you use the tone function on the Arduino you cannot use PWM on pin 3 because they share a timer. Check out the Tone page on Arduino.cc
http://arduino.cc/en/Reference/Tone
'Use of the tone() function will interfere with PWM output on pins 3 and 11 (on boards other than the Mega).'
-Sam K
LIFA Developer
10-02-2011 07:09 AM
Thanky you Sam for your reply.
There is a note "if you want to play different pitches on multiple pins, you need to call noTone() on one pin before calling tone() on the next pin."
How can I do it?
Did you try such a solution?