LabVIEW Interface for Arduino Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Color LED (3 x PWM) + Buzzer (1 x PWM) = problem

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?

follow your dreams
0 Kudos
Message 1 of 3
(5,276 Views)

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

0 Kudos
Message 2 of 3
(3,089 Views)

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?

follow your dreams
0 Kudos
Message 3 of 3
(3,089 Views)