Blinking LEDs at 64Hz for Mosquito attraction

I recently came across a scientific journal report that claims blinking LEDs at 64Hz will increase the attraction (collection) of mosquitoes up to 2.5 times. I built several traps using LEDs, 80 and 120mm fans and Nano and Pro mini computers. I'm actually wiring 3 sets (each set is a different nano meter wave length) of 4 LEDs in series to eliminate resisters because I can run the fan and computer with 12 volts. I use a mosfet to transfer the led load away from the computer. It seems to work and I do collect some bugs.

The journal says that they propose using PWM to blink the LEDs because they are using solar recharged batteries to power the unit in the field and want to save as much electric as possible. I don't have that requirement because I'm just using a 12 volt wall charger (wall wart).

I'm not a NOOB with Arduino computers, having built my own design 3D printer, golf ball logo machine and about 50 other projects. BUT I'm completely confused about how to implement PWM. So can anyone tell me if my approach of just using digitalWrite to turn on/off the LEDs with a 7.8125 delay is acceptable to blink the LEDs at 64Hz? I know the Arduino world hates using delays, (me too) but there is really only 4 lines of code in the loop.

If you're doing nothing else, "delayMicroseconds (78125)".looks OK to me.

Sounds like it would work. A bit overkill to use an Arduino for such a trivial thing, but why not.

I purchased a bunch (20 or so each) Arduino computers from Mega 250's to attiny's for about a $1 a piece on average. I thought about using an Attiny ($.50) but adding the required 12 volt to 5 volt reducer just adds to the cost and and wiring complexity. The Pro mini (I have to use a FTDI programmer) works great and the Nano is the easiest of all. I'm only building a half dozen of these for friends. For $30 I can buy pretty much the same thing EXCEPT they don't do the 64Hz blink. So this is really just a learning exercise for me. (I just turned 74 and I'm still programming the crap out of these things!)

4 LEDs in series to eliminate resisters because I can run the fan and computer with 12 volts.

LEDs are "current operated" and should ALWAYS have a resistor (or some kind of current limiting or current control).

But doesn't wiring 4 of them in series (3.2 volts x 4 = 12.8 volts) accomplish the same thing? To my mind the resistor just "bleeds" off the extra voltage as heat. But in this case I'm actually underpowering the LEDs slightly. I'm not a EE so maybe I'm missing something.

Also do you mean 7.8125 not 78125? 1000 microseconds divided by 64 = 15.625 cycle time. 15.625 cycle time divided by 2 (equal on time off time) = 7.8125 microseconds delay. Right?

So here is the full Magilla, for anyone who is interested. 2" PVC "T" (I'm up to 3" now with a 120MM fan), 80 mm 12 Volt fan. SCAD designed and 3D printed fan and bug trap adapters. Nano or Pro Mini with mofset on a breakout board (easy peasy wiring!) 1 set of (4) 10mm purple (395 nm) led's. 1 set of (2) 5 mm green led's and (2) 5 mm blue led's. On the 3" I have just received 10 mm blue and green led's for it. Powered with a 12 volt wall wart. I used black panty hose from the Dollar Store ($1) for the bug trap bag. I need to go get more but I'm in quarantine. If you like it, please copy my idea. Don't use it for commercial purposes, I think the Chinese have a patent on the 64Hz stuff.

Again, for those that responded to me, thank you very much. You are great.

No, 78125 microseconds.

WOW. You got me there. I was thinking 1,000 microseconds in a second. Goofy me. That's milliseconds.
So yes, thank you very much it is 78125 "microseconds" in the delay. I guess I'm still in the NOOB category!

See reply #1

tone(pin, 64);

Well the tone command is an elegant solution. I'm guessing it goes in setup rather than void loop for continuous use.

Thanks for this. I didn't even think about this command.

I have several "BUZZKILL" machines running, so I can test out all the combinations, ie; commands, led combinations, etc.

Many thank again.

BruceMacIntyre:
I purchased a bunch (20 or so each) Arduino computers from Mega 250's to attiny's for about a $1 a piece on average.

I'd really like to know where! :astonished:

Mostly from Banggood, but I'm not here to promote vendors. They have been ok over the years with a couple of orders lost in transit with no recourse. They claimed they were delivered and I claimed not so. Too bad for me. And it usually takes several months to get stuff, but so far, everything works. It's been quite a few years since bought them at different times. I watch for sales and then I buy usually about 20 at a time. A lot of the computers were Attiny chips and breakout boards, so that lowered my average $ quite a bit. But I get the most use out of the Nanos that I paid a little over $2 for. I think they are the best bang for the buck. I just ordered some more Nanos a couple of months ago from Aliexpress for $1.80. I'll admit prices have gotten much higher but I remember that I paid about $75 for my first Mega 2560 from Radio Shack! Have fun shopping.

And I would agree that the Nano is the most practical form of the Arduino. :grinning:

The UNO is too cumbersome with its odd arrangement of female connectors, while as soon as you say "WiFi", you should forget Arduino and go to the ESP8266 versions. :sunglasses:

BruceMacIntyre:
But doesn't wiring 4 of them in series (3.2 volts x 4 = 12.8 volts) accomplish the same thing? To my mind the resistor just "bleeds" off the extra voltage as heat. But in this case I'm actually underpowering the LEDs slightly. I'm not a EE so maybe I'm missing something.

What you're missing, is that LEDs don't have a linear relationship between current and voltage the way resistors do (V=IR). Instead, they have an exponential curve. It makes them extremely sensitive to voltage, which is a non-issue as long as they are current driven. The current limiting resistor functions as a crude current source for the LEDs. It gets worse - the "knee voltage" decreases with temperature, and causes an increase in current when fed only from a voltage, which causes an increase in temperature, and so on down the road to destruction, called "thermal runaway".

The scientific report

Are you using 395 nm UV LEDs?

I was obviously being too literal when I said these were $1 each on average. Before I retired I was used to paying $15,000 for a redundant, raid file server and $20,000 for a High performance SUN workstation for my high speed laser printers (150 PPM).

So these little buggers seemed almost free to me. Here is a summary of the recent prices I have paid. Much of what I have in inventory was from several years ago and it was even cheaper then.

MEGA2560 - 6.90
UNO - 3.19
Nano - 3.80 3.19 3.39 2.40
Pro Mini - 2.24
AT85 - .85 .90
ESP32 - 6.00 5.25
ESP8266 3.00 (with oled display and DHT11!)
Breakout board for AT85 - .80
Screw lug breakout board for Nano - 1.90 (makes wiring really easy and reliable compared to boards).

And I agree mostly with the last reply that the Nano is one of the best packages.
For the longest time I really didn't care much about the price because everything was so cheap so I just used MEGA's for everything. But recently I did a couple of projects to remotely monitor a greenhouse's temperature during the winter and the ESP32 was amazing for that project. WIFI link to the greenhouse and email and text messages to 4 people responsible for the greenhouse.

I like the Pro Mini but hardly worth the trouble to plug in FTDI every time I do a software change. Same for the AT84 and 85's that I've used. I built a ZIF socket programmer for those.
I have a bunch of UNO's and never found much use for them.

But all in all they all have been great fun and interesting learning experience.

Yes, I'm using the "purple" 395 nm (or about) Ultra Bright, 10 mm led's. I got a bag of 50 thru amazon with LighthouseLEDs.com

The resistor stuff makes more sense now. I was just being to simplistic adding up all the voltages of the LEDs to about equal the power source. I have done this quite a few times and never burned out a led. But I'm going back and fixing everything. I found a online calculator that makes figuring out the resistor easy.

Thanks again everyone for all your input. I'm really impressed with the help I have received and willingness to share knowledge. Again, many thanks.

Happy Bug Hunting!