Turning on the Bright Lights, Part 1

Turning on the Bright Lights, Part Deux” is also live.

Story So Far: Heater prototype didn’t work, waiting on alternative parts. Playing with using pwm (unimportant technical term) to control some LED bulbs for the lamp.

TL;DR: I set up a dodgy circuit to test the lamp part of the alarm clock. Plugged said dodgy circuit into my laptop and gave the PC a fairly debilitating case of agoraphobia. Shock therapy not advised.

I think experimenting with the lamp made for a high-octane chain of disasters so I think I’ll use a sort of dramatic retelling to detail how I transcend the limits of my single-headed human form to fit so much stupid in. How Does That Grab You, Darlin’?

While waiting on new parts for the new heater I figured I could work on the lamp, this would have to be addressed at some point anyway and it would be a nice proof of concept for the heater circuit as they are identical in all the ways that matter. So, out to the garage I went, full of misplaced complacency and bright ideas about this lamp. I set up a very simple circuit1 which is stylised to be even simpler below.

Left: Stick person controls dimmer switch for light bulb, powered by car battery
Right: Arduino controls current flow through a MOSFET (3-legged box which I forgot to label) to control the lamp circuit, powered by 12V supply


After having set up the hardware I had to tackle the minor issue of the software; just a little bit of code to make the lamp brighten/dim brighten/dim repeatedly. My laptop had been enjoying a well earned rest up until that morning – it’s a coin toss between it and the kettle for hardest working appliance throughout my final year of uni – nonetheless it sprung to life right spritely like and was ready for a new project; like an over-zealous sheepdog pup; keen to impress.

Brightness of the lamp is on a scale of 0 – 255 so I set about writing code that would peruse said scale up and down at intervals of 5, updating every second.

Once the code was written, I began uploading it to the Arduino. The Arduino blinked intensely and thoughtfully while it tried to comprehend its instructions and commit them to memory, then, once it felt it had a grasp on them it returned to its steady state; a bright-eyed thousand-yard stare2. This vapid expression concealed a mind that was furiously rehearsing the instructions which now constituted its entire raison d’être. The only thing that could interrupt this fervent meditation was the command to effectuate these orders and begin actually making the world a brighter place – just waiting on the word “GO”. Like a well-disciplined (read indoctrinated) soldier, not yet jaded by combat. The word “GO” in this case was me hooking the Arduino up to the big ol’ 60-Watt power brick. Using a 60-Watt supply to run a circuit this modest is a bit like using a forest fire to dry your hair but I’m told that the Arduino knows exactly how to keep its distance and not get set alight so I went ahead and gave the order anyway.

Turn on the Bright Lights


The lamp came on immediately when connected and was beaten only by my celebratory smile for brightest thing in the room. However, for every second that passed without the lamp getting any dimmer, my expression picked up the slack; finally my face was furrowed and frowning in equal measures at the failure. My first guess was that there was a bug in the code and the brightness level wasn’t updating as it should. So, I opened the laptop and started rewriting the code in a more obvious, less succinct way. Just by habit at this point I had also disconnected the lamp from the Arduino.

At this point I had both the big ol’ power supply from the wall and a USB lead from my laptop going into the Arduino and as I reconnected the lamp circuit it came on with that same, persistent full-beam of failure . . . the garage didn’t seem all that much brighter. Not metaphorically or anything. It was because my laptop screen had gone to sleep at the same time. I hit the space bar a smack to wake it up again (and perhaps vent some anger at my incompetence), but the screen remained black. Interesting. Immediately I ripped the USB lead out from the laptop. Intuitive. I turned all off and began CPR on the laptop. On-button compressions triggered a gasp of air through the fans but it still remained unresponsive, after 40 minutes of poking and prodding we had him back and fully lucid. The diagnosis was that a rush of current from the Arduino into the laptop’s USB port triggered some sort of safety feature that protects the motherboard; this feature cuts the machine off from the outside world until a certain secret knock on the power button lets it know the coast is clear. While researching it I discovered “USB killers”; pen drives that when plugged in, give a massive shock to the motherboard to try and fry it and brick the target machine, honestly, that’s their only purpose – a perfect, pocket-sized example of man-kinds malevolence. I’m glad they exist though because if they didn’t the safety feature I triggered might not exist and my laptop could very well be toast right now.

Turning on the Bright Lights, Part Deux” is now live to conclude this part of the build.

1 – If you’re technically inclined, the actual circuit I ended up using is drawn and carelessly discussed below. In the picture of the physical circuit up above though you can see I only have one resistor in *spoiler alert for part two* it’s not the important one.
2 – Arduinos actually do have an LED that blinks while they load up with new instructions and then switches to a fixed on state to show it has accepted the new code. This isn’t just me rambling. Let me try again. This isn’t just me rambling.

Probably the final circuit schematic

Blue box = Arduino
Red box = MOSFET
Basically Vin will put 12V across the LED light when the MOSFET is set as a short circuit. The MOSFET will be set as a short circuit when its gate pin has a voltage applied to it (when pin D2 is high [It won’t be pin D2 in reality, it’ll be one of the pwm pins to allow variable brightness]). There’s a 10 K-ohm resistor from gate to ground on the FET to avoid floating states. The two 220 ohm resistors are just current limiting resistors. D1 will be polled continuously, if the button is pushed, D1 receives a signal from the 5V rail and the Arduino toggles the state of the lamp (fully on/fully off) as long as it isn’t already in the middle of brightening the lamp for the morning routine.

Create a website or blog at WordPress.com

Up ↑