First up, let’s wire up our contraption! Take your Raspberry Pi and connect up the keyboard and HDMI display.
Now we need to take the lantern apart to reveal its power wires. As you can see, after removing the 4 screws on the battery-holding base, we gain access to the RED (5v) and BLUE (GND) wires. To turn the lantern on or off, all we need to do is send 5v down these wires!
We will be using a transistor send this voltage and turn the lantern on and off. Why not just connect the input of the lamp straight to the RPi, you ask? Well, this is because the RPi’s control pins (also called “GPIOs”) are unable to output the power we will need to illuminate the lantern. The transistor works in a similar way to a relay, like an electronic switch which passes current through it when a voltage is applied.
Each Friday is PiDay here at Adafruit! Be sure to check out our posts, tutorials and new Raspberry Pi related products. Adafruit has the largest and best selection of Raspberry Pi accessories and all the code & tutorials to get you up and running in no time!
Make a robot friend with Adafruit’s CRICKIT – A Creative Robotics & Interactive Construction Kit. It’s an add-on to our popular Circuit Playground Express, FEATHER and other platforms to make and program robots with CircuitPython, MakeCode, and Arduino. Start controlling motors, servos, solenoids. You also get signal pins, capacitive touch sensors, a NeoPixel driver and amplified speaker output. It complements & extends your boards so you can still use all the goodies on the microcontroller, now you have a robotics playground as well.