# Lightning Simulator Attiny85



## Jekyll-labs (Jul 28, 2021)

Hi All,

I just finished a quick re-build of a lightning simulator using a Attiny85 and wanted to share the results.






The light is a 12v flood lamp (like this one for automotive uses), and is plenty bright to light up a room (or blind me temporarily if I look in the wrong direction). The rest of the parts are pretty cheap. $4 for the capacitors, voltage regulator, and mosfet, and maybe $2 for the Attiny85. It’s super easy to build on a breadboard, but I was already printing a PCB for something else, so I added on to the order.

Here are the schematics and Fritzing diagrams.

Is anyone else working with Attiny85 chips? I see a lot of the older posts using PICAXE chips, but I’m more familiar with the arduino ecosystem.

As an aside, this is a great project for those getting started with Arduino. If you use an uno or nano, you only need to buy the mosfet, the light, and the power supply.


----------



## corey872 (Jan 10, 2010)

Looks neat! I'm sure the camera doesn't do it justice to actually being there. I haven't done any work with the Attiny's or PIC's. Pretty much just grab an arduino for whatever I need. I've actually done a 180 degree turn... years ago, I couldn't see why anyone would use an arduino when they could just build a small, simple circuit. Then I started realizing one arduino could cover just about every 'simple circuit' I ever built, plus a ton more!

With that said, I have done some strobe, flicker and lightning effects with the arduino - generally make pretty good use of the 'random' function - to keep things lively, but still in sort of a jittery / natural / random nature.


----------



## SouthBayJT (Oct 10, 2010)

This is really neat; thanks for posting it. Does it seem like that LED flood lamp turns on and off pretty quickly? I'm currently using an old incandescent photo flood bulb with a channel light organ that syncs to thunder sound from a 3.5mm input, but I'd like to evolve this arrange to something with LEDs; this seems like a promising arrangement, or maybe one of these LED floods with an Arduino and timed to flash at the same moment of the thunder sound. I assume the LEDs are pretty much on or off? IE, not dimmable? That behavior would be slightly different than the incandescent, which can show subtleties of brightness, but most lightning flashes I see these days (such as the Pirates of the Caribbean ride) are on/off anyway.


----------



## Jekyll-labs (Jul 28, 2021)

Thanks! The LED floodlight gives a very nice immediate level of max brightness. All of the settings (duration of flash, number of “daughter” flashes, etc) are all editable in the code. LEDs are dimmable. Most commonly they are dimmed through something called Pulse Wave Modulation. It flashes the LED faster than human perception and the brain averages it out to a dimmer bulb.

The system as it’s currently set is just the flashes. There is no audio synchronization. That’s something I’ve been thinking of though. Maybe a project for post Halloween.

I’ve also been working on a board with some other lighting effects (dimming, pulses, firelight, and lightning). I put a bit of a write up in the other forum as well as code and schematics that are in my blog.


----------



## SouthBayJT (Oct 10, 2010)

Wow! That board is crazy-cool. You can achieve so many things with this, and I see what you're saying--the LEDs are definitely dimmable, because that firelight effect looks great.

Okay, you've definitely got my attention on this. I've worked with Arduinos before, and I'm comfortable with the coding part, but building the separate board & reading the schematic is trickier for me. 

I'm going to take a crack at building this--can you explain the parts involved in the blog post?
Here's what I understand so far:
Potentiometer--The blue component with the Phillips adjustable dial that varies the resistance.
IRLB8721 mosfets--These use the low-voltage of the Nano to turn on/off a higher-voltage path (basically like a relay?).
Screw terminals--You connect your LEDs' separate power source to these, which gets routed through the mosfet in order to switch it on/off or dimmed.
Resistors--It looks on the schematic like there are a couple of resistors, but I don't see those on the Fritzing diagram? Can it be built without those?


----------



## Jekyll-labs (Jul 28, 2021)

SouthBayJT said:


> Wow! That board is crazy-cool. You can achieve so many things with this, and I see what you're saying--the LEDs are definitely dimmable, because that firelight effect looks great.
> 
> Okay, you've definitely got my attention on this. I've worked with Arduinos before, and I'm comfortable with the coding part, but building the separate board & reading the schematic is trickier for me.
> 
> ...



Hey! Glad you like the board. Here’s a video that shows the modes all together:





You should totally build this. It’s not hard, and I’m really pleased with the effects. With regard to your questions above:
Potentiometers - 10k trim potentiometers. Basically a 10 kOhm resistor between ground and power with a sweeper that gives a resulting voltage that the arduino reads as 0 to 1023

Mosfets - yes sort of like a relay. Briefly, relays lets one circuit control the other. One could be AC, the other DC. Mechanical relays can be more powerful, but they are slower and noisier. For mosfets and bipolar transistors, both “sides” are DC and they share the same ground so it’s really one big circuit. In this circuit the Mosfets work as a “low-side switch” that turns on/off the ground leg of the 12V lights circuit.

Screw terminals - Most useful because I wanted to hook and unhook from my PCB board, if you are building the circuit on a bread board, you will not need.

Resistors - in the schematic the resistors you see are actually the 10K trimpots mentioned above. You should note, I follow the lead of Adafruit and Sparkfun and don’t use gate resistors between my arduino and the mosfets. There are a variety of opinions on this.


----------



## mc510 (Sep 23, 2018)

Jekyll-labs said:


> Is anyone else working with Attiny85 chips?


I used a Digispark Attiny85 arduino to make a flickering light/failing electrical circuit effect. Basically just some calibrated random number generation that controls a solid state relay, which makes the AC current flicker on and off. I also have it make some very rudimentary static noises driving a piezoelectric speaker, synchronized with the flickering light. I actually don't remember how I did that part! I should go back and look, because it was always intended to be temporary, to be replaced with some real audio effect.

Now, I just ordered a 50W led this afternoon with intention of making a lightning effect, so I'm glad I found your project! I like the way your light cuts on and off instantaneously, rather than ramping up and fading out. Curious how the led that I ordered will behave. And I'll be eager to read up on how you synchronize sound; I don't have any good ideas on that yet.


----------



## Jekyll-labs (Jul 28, 2021)

Awesome. Would be great to see your code if you find it.

There is actually quite a bit of discussion currently on the other forum regarding syncing lights to thunder audio. I have a few KA2284 chips that I intend to mess with once Halloween is over.


----------



## mc510 (Sep 23, 2018)

Jekyll-labs said:


> Awesome. Would be great to see your code if you find it.
> 
> There is actually quite a bit of discussion currently on the other forum regarding syncing lights to thunder audio. I have a few KA2284 chips that I intend to mess with once Halloween is over.


Okay, here is the code for my "failing electric circuit" effect. It was my first Arduino project, and my last (at least so far). Apparently I thought it was important that that timing of the static be normally distributed? I was intending to replace the crappy "tone"-generated static sound with a synchronized mp3 of quality static, but now thinking maybe I should start with a long recording of sparking sounds and use the circuit from the other discussion to synchronize the light effects. Anyways, for now, the flickering of the lights is quite satisfying, though the sound effect is poor.

[edit]@Jekyll-labs I've read that other thread over several times, and keep bumping up against the fact that I do not understand electrical circuit design _at all_, and I have no idea how to make the small mods to that circuit that I'd want. I'm thinking now about a very different path of taking a nice audio recording of crackling/sparking type static and (1) feeding it into an amplified speaker, and also (2) sending it to an Arduino with some simple code to monitor the voltage of the audio signal and flip one of its outputs on/off based on the level, with a solid state relay attached to that output. Think that would work?[/edit]


----------



## corey872 (Jan 10, 2010)

Jekyll-labs said:


> ...regarding syncing lights to thunder audio...


lol, and here I have spent all my time UN syncing lights to thunder audio. Thinking the lights should flash first, then the thunder is heard. Or if you really get nit picky, the lights flash, thunder is heard and the two slowly get closer together until....


----------

