We wanted to get into the Halloween spirit at BreakoutBros but we are super busy writing reviews, tutorials, and decorating our houses. While I was testing parts to review the ControlEverything.com Arduino Shield I realized I was just a few spliced wires and a relay away from something fun.
So I combined that shield, the Arduino Light Control Tutorial, a ceramic Jack-o-Lantern, and some wire. The pumpkin I used already had a male plug, so I decided to make a relay controlled outlet. This also made it easy because modern wall outlets have places to simply push in wires. That way I didn’t need to use any wire nuts, just the screw terminals on the relay board. I even used the Normally Closed terminal on a 2nd relay for the return wire.
To keep my dogs out of the wires, I put all the hardware in a shoebox and plugged in the Arduino and Pumpkin.
In the spirit of keeping it simple I have it come on when the button is pressed and stay on until its released.
Here is the code:
void setup() {
pinMode(5, OUTPUT); //Set up the pin for the Relay
pinMode(13, OUTPUT); //These two lines turn OFF the buzzer
digitalWrite(13, LOW); //The buzzer is rather useful most of the time
}
void loop() {
if (digitalRead(6) == HIGH) //check for remote press from the shield
{
digitalWrite(5, HIGH); //Close the relay to turn on the light as long as the button is held
}
else
{
digitalWrite(5, LOW); //leave the light OFF otherwise
}
}
Even my dog wanted to check out the show.
The great thing about this is how easily expandable it is, you could add a motion or proximity sensor to make it automatic or you could add a speaker and audio shield for a sound effect.
Happy Halloween Everyone.
Comments
Please log in or sign up to comment.