Step 5The Electronics
Since using an AVR microcontroller is out of the scope of this instructable anyway, and you would need existing experience, I'm hoping that providing the firmware (attached as 'main.c' below) will be enough to get you going. Of course, if there are any questions, please ask and I'll help as much as possible.
Suffice it to say, the signal for controlling the LED array is connected to pin 12 (PD6), the 'temporary off' switch is connected to pin 4 (PD2), and the LDR is connected through a voltage divider to analog pin 23 (PC0). I set up internal PWM, and simply change the PWM value based on the LDR analog reading. It's probably pretty messy, but it was my first real project with the AVR by itself. Any suggestions for improving the code would be welcome!
main.c2 KB| « Previous Step | Download PDFView All Steps | Next Step » |












































Also, I may be missing something completely, but you have the firmware included, but is there no place to see how this curcuit is wired? I mean, I can see you have a switch and a resistor, maybe two, looks like maybe an IC, a jumper and a few other things, but I'm just not getting how it's wired. I know you said you have no place to create a schematic, so I gave you the link to that freeware(it works really well by the way), but as somebody esle pointed out if you could just throw a drawing on a piece of paper that would be awesome. I am really interested in doing this.
Also, the LED's you ended up using you said were put together in series, so when you took them apart you didn't have to re-solder them right? All you did was put the LED's you already had in series and then put those in paralel correct?
Another thing. Since I don't know how this is wired or anything, do you think it would be possible to add in moonlight that would gradually increase and then decrease just like the daytime lighting?
Sorry for all the questions, I'm just really interested ini this.
As far as the unused component, you're correct, it's a DC plug that Iwas using for power while I was working on the circuit on mybench. I left it there in case I decided to pull the board out tothrow in more changes. As it is, the braided wire provides powerto both the circuit and LEDs at the same time.
For the LEDs, indeed I DID resolder them. Take a look atthe photos and you'll see what I mean. I soldered several stringsof 4 LEDs in series, and then wired all of the 4 LED strings in parallelwith each other. That means 12V is provided to 4 LEDs at a time,for 3V each. As long as your power supply is a steady 12V, thisshould be fine. YMMV.
I'm not sure how this site works, but I'm planning on making a fewchanges to your design for safety and usability. For one I have touse insulated wire to put the LED's on. I have been designing andmanufacturing electronics for some time now and looking at that makes mecringe lol I'm gonna use a single core copper wire it will beanywere from 14 to 22 AWG and insulated. I'm also going to cover thoseflat nuts and bolts that you have on the side of the lid so I don'tshock myself. Just an idea for ya
I'm not sure if a moonlight switch would be possible or not, at leastnot in the same way. I'm not sure if an LDR is sensitive enough todetect the moonlight, and I definitely think you could have issues withstreet lights or other outdoor lighting causing it to getconfused. Since the sun dwarfs these, it's easy enough to filterout the less intense light.
That being said, as I mentioned in one of my other comments, the IRF510seems to have a certain amount of bleed voltage when at 0 in my case, sothere is definitely a slight 'moonglow' at night with mine, it justdoesn't change intensity through the night.
Incidentally, I've been using this setup for a solid 6 months, and havehad ZERO side effects on either plant life or fish life. The tankseems to be perfectly happy. I hope it works out the same for you!