Project tutorial

The Troll Switch © GPL3+

Turn Off the light, and it will turn ON: endless fun!

  • 1,560 views
  • 3 comments
  • 6 respects

Components and supplies

Apps and online services

About this project

Off. On. Off. On. OffOn. OffOnOffOn...

The light switches ON when someone turns Off the light. This is my circuito.io's Arduino Day Prank Contest prank!

Using the platform, I ended up this circuito.io link. There, you will find some sections, which will help you build the project.

Story

The main idea is simple: switch ON the lights whenever someone (tries to turn) turns it OFF. At first, I thought about connecting the Arduino directly to the light wiring (or some sort of wireless switch) but then I thought it would be easier to put a Servo on the light switch. Since it is a prank, not-very-house-changing project is better. Since I'm always doing some electrical stuff in my house, it won't be a strange thing for the possible victims :D

First Things First

So, as always, the first thing we need to know is the bill of materials. This project doesn't use many components, so it was pretty straight-forward.

With these materials, circuito.io automatically creates the wiring diagram, which in this case is this one:

Real Life

Now, it's time to build the project itself. Following the step-by-step guide on circuito.io, I got this:

The next step on the list is the code. On circuito.io, they provide a sample code wich you can upload directly to your board (Arduino UNO in this case). Beware! As they say, you should extract the whole .ZIP folder and then open the file, so no file is missing. Here is the code I got for my project (Firmware.ino):

Final Steps

Once we know everything works OK for sure, it's time to upload the final code to the arduino. At the bottom of this page, you will find a file called "The Troll Switch.ino", which you have to copy on the Arduino IDE and upload to the board.

Now, the last step is to hide the cables and the Arduino. I used a flower pot because it fitted almost magically, be creative here!

All you have to do is put a hidden camera, and prepare yourself to laugh. Happy pranking!

Results

Here is a video of the prank:

The Prank

And here anotherone with an "explanation":

The explanation

Thanks to Julia and Asier for starring these videos :D.

Any suggestions or questions, just leave a comment!

Code

The Troll SwitchArduino
Here's the program for the joke. Upload it to the mounted Arduino and ready to go!
#include <Servo.h> // We need this library to operate the Servo

int LDR = A3; // We connect the LDR to the A3 pin
int light = 0; // A variable to avoid infinite moving loop
long randomTime; // We will store the time here later

Servo myservo; // We will call our servo "myservo"



void setup() {

  pinMode(LDR, INPUT); // The LDR will act as an INPUT

  myservo.attach(2); // We will connect the Servo to digital pin 2

  Serial.begin(9600); // To start the Serial communication, useful for debugging

  myservo.write(20); // At first, we need the servo at this position

}



void loop() {

  if (analogRead(LDR) < 100 && light == 0) { // If the light value is less tahn 100 (and the light variable is set to 0)

    randomTime = (random (0, 5) * 1000); // The time will be a random number between 0 and 5, multiplied by 1000 to make it into seconds
    Serial.println(randomTime); // This will print the time (for debugging)

    delay(randomTime); // The Arduino will wait that random time

    myservo.write(80); // And then move the Servo to de 80 position
    delay(200); // Wait for 0,2 seconds

    myservo.write(20); // And move the Servo to the initial position (20)

    light = 1; // This will set the "light" variable to 1
  }

  if (analogRead(LDR) > 99) { // If the light value is higher that 99 (A.K.A the light is on)...

    light = 0; // The "light" variable will be set to 0

  }

  Serial.println(analogRead(LDR)); // The light value will be printed
  delay(500); // Wait for half a second
}

Schematics

The Troll Switch Circuit Diagram
The same as above, made with circuito.io
Wiring o6a7fb2yb7

Comments

Similar projects you might like

No Candy For YOU!

Project tutorial by Jonathan Tindal

  • 1,353 views
  • 5 comments
  • 7 respects

Arduino Darkness Activated Ghost

Project tutorial by Technovation

  • 2,799 views
  • 4 comments
  • 13 respects

Pranked! Moving Tissue Box | Circuito.io

Project tutorial by Arduino “having11” Guy

  • 5,462 views
  • 1 comment
  • 22 respects

The TrafficLight

Project showcase by Advaith Jagathesan

  • 15,723 views
  • 1 comment
  • 23 respects

LED Color Sequencer

Project tutorial by Team thefantasticode.Group

  • 7,170 views
  • 14 comments
  • 25 respects

Wireless Light Switch Manipulator

Project tutorial by Becky Button

  • 5,128 views
  • 7 comments
  • 18 respects
Add projectSign up / Login