I haven’t got a house to decorate so I thought I would put a few LEDs (16, to be exact) on a smaller, edible version!
- 16 yellow LEDs
- 1 photocell (light sensor)
- Arduino UNO
- Breadboard + wires
- Conductive dough, see yesterday’s post for instructions
- A gingerbread house kit
1) Build the house
Unfortunately, I haven’t got the time to bake my gingerbread house (I’ve got to keep the LED counter going!), but I was lucky enough to get a gingerbread house kit as a(n early) Christmas present; so I thought I would put it to good use in one of these projects!
Let’s start by building the house, as per the instructions, but don’t seal the top with icing. Once it’s been left to set for 30 minutes, fix the top of the roof with some left over (or freshly made) electro dough from yesterday’s activity. Plant the positive lead of your LEDs in the dough. Add some dough on one side of the roof, that’s where the negative lead should go. The dough is made of edible ingredients only, so no worries on that side (it might not taste great, though…). Ensure the strip of dough on the top, and the one on the side don’t touch or the LEDs won’t light up.
Plant some wires into both strips of dough, and into a breadboard.
2) Adding a light sensor
To get the light sensor working and affecting the LEDs, we are going to use the Analog In Out Serial example available in the Arduino IDE, all you have to do is replace the potentiometer by a photocell and a 10K resistor.
Test your LEDs and photocell, and using the output of the Serial monitor, adjust the threshold of your sensor, by modifying this line:
outputValue = map(sensorValue, 0, 1023, 0, 255); to get the desired effect.
We also want the LEDs to light up when it’s dark, so we need to invert the last two values. Mine ended up looking like this:
outputValue = map(sensorValue, 0, 720, 255, 0);
Finish the icing and decorating of your gingerbread cabin.
Now we’ve got a wintery house that lights up when it gets dark! 🙂