Need Help Controlling An Led

 
#1

Hello!

I have a project that I need to create an animation paired with a sound file.

I need to be able to control a single LED and have it randomly flicker when I play a sound file of a Tesla Coil arc crackel. The LED is on the tip of a fake Welding Arm.

Anybody have any ideas?

Thank you!

Doug

#2

A simple and crude way is to PWM the led according to the sound volume from you PC speaker and mic or ezb4 speaker. Using the variables $SoundValue or $Soundv4Value to vary the brightness of the led according to sound volume

Code:


#if using sound Servo Mic control
PWM(D0,$SoundValue)
#or if using Sound servo EZB control
PWM(D0,$Soundv4Value)

#3

That's a great idea! So the LED just plugs into D0? I have a resistor on the LED so it won't be cooked over 9 volts.
User-inserted image

#4

Yes, you use ground and the signal pin (not the red power pin) of any of the ezb's digital ports...You need to be more concerned about the ezb's port than you do about the LED.. So be aware your led will need a resistor (if it doesn't have one, but you mentioned it does) as the signal pin can only provide 10mA @3.3v... Any device drawing more than 10mA on an ezb4 signal pin risks blowing the port...

#5

Thank you so much! I'll try it tonight.

#6

At 3.3v of the ez-b v4's signal pin, a resistor isn't necessary - adding one will dim the led significantly. The ezb i/o drive is quite minimal, i never bother adding resistors. I mean, it's not per spec, but hey, who cares sometimes Grin

If you find the led is dim, remove the resistor

#7

@DJ... Thanks... good to know... I probably got confused since I used resistors with the ezb3 as it had 5v on the signal pin...

#8

The ez-bv4 has in-line 330ohm series resistors with the I/O ports so at 3.3V you can't draw more than ~10mA by hooking an LED directly up to it. It's a built-in safety feature Smile

#9

@Jeremie.... thanks, that clears up a lot... Smile

#10

Thanks everyone!