Astley-izer

by Grissini in Living > Pranks, Tricks, & Humor

2270 Views, 5 Favorites, 0 Comments

Astley-izer

RickRoll.png
IMG_0243.JPG
IMG_0244.JPG
waveshield.jpg
A Rick Roll for real life.  If you somehow missed the internet meme of Rick-rolling,  http://en.wikipedia.org/wiki/Rickrolling(read this).  I want to take this meme from the internet to the real world. Enter my trusty wave shield and PIR sensor.  A real easy build and software mash-up.   

Parts:

Arduino Uno
Adafruit WaveShield
Parallax PIR
Some wire
A project Case

How to:  Download "Never Gonna give you up", covert the file as per Ladyada's instructions for the wave shield(Must be .WAV at 16bits and 22hertz), Connect the PIR to 5volts, Ground and Digital Pin6 on the wave shield.  Upload provided code to the arduino, place the wave shield on it, throw it in a discreet case.  Voila you're done.   Now go Astley up the place.  

One other RickRoller out there, this one uses a timer and more electronic gadgetry.  Mine is ridiculously easy and fun for messing around with random strangers.  I've rickrolled some random people so far,  Most don't find it nearly as funny as I do.  




Yay Video.  Sorry but all I have right now is built in laptop webcam.  Doing the best I can with what I got.  Put a laser cutter in my hands and I'll Make something EPIC.  Hint, Hint.  
 

I rick-rolled my girlfriend half a dozen times tonight in our small Residence Inn suite.    My joy was uncontained. The surprise is everything.  Sorry I didn't capture her delight at being pranked.    It's tough to leave video running for hours to capture the few moments when someone will walk by my Astley traps.  But I assure you, its worth the staking out some place. 

THE CODE:  Credit where its due, left some for Kristian Gohlke,  LadyAda also gets mad props for being so Amazing!  Thx Limor.  I couldn't have begun to do this without your products, awesome code and inspiration attitude. 
	/*
 * //////////////////////////////////////////////////
 * //making sense of the Parallax PIR sensor's output
 * //////////////////////////////////////////////////
 *
 * Switches a LED according to the state of the sensors output pin.
 * Determines the beginning and end of continuous motion sequences.
 *
 * @author: Kristian Gohlke / krigo(_)web.de / http://filformat.net
 * @date:   3. September 2006
 *
 * kr1 (cleft) 2006
 * released under a creative commons "Attribution-NonCommercial-ShareAlike 2.0" license
 * http://creativecommons.org/licenses/by-nc-sa/2.0/de/
 *
 *
 * The Parallax PIR Sensor is an easy to use digital infrared motion sensor module.
 * (http://www.parallax.com/detail.asp?product_id=555-28027)
 *
 * The sensorĀ“s output pin goes to HIGH if motion is present.
 * However, even if motion is present it goes to LOW from time to time,
 * which might give the impression no motion is present.
 * This program deals with this issue by ignoring LOW-phases shorter than a given time,
 * assuming continuous motion is present during these phases.
 *


 */

/////////////////////////////
//VARS
#include 
#include 
#include "util.h"
#include "wave.h"

AF_Wave card;
File f;
Wavefile wave;

int calibrationTime = 30;	  //the time we give the sensor to calibrate itself (10-60 secs according to the datasheet)
long unsigned int lowIn;	   //the time when the sensor outputs a low impulse
long unsigned int pause = 5000;  //the amount of milliseconds the sensor has to be low before we assume all motion has stopped

boolean lockLow = true;
boolean takeLowTime;

int pirPin = 6;    //the digital pin connected to the PIR sensor's output
int ledPin = 13;


/////////////////////////////
//SETUP
void setup(){
  Serial.begin(9600);
  pinMode(pirPin, INPUT);
  pinMode(ledPin, OUTPUT);
  pinMode(2, OUTPUT);
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);
  digitalWrite(pirPin, LOW);

  //give the sensor some time to calibrate
  Serial.print("calibrating sensor ");
    for(int i = 0; i < calibrationTime; i++){
	Serial.print(".");
	delay(1000);
	}
    Serial.println(" done");
    Serial.println("SENSOR ACTIVE");
    delay(50);
     if (!card.init_card()) {
   return;
 }
 if (!card.open_partition()) {
    return;
 }
 if (!card.open_filesys()) {
    return;
 }
 if (!card.open_rootdir()) {
    return;
 }
  }

////////////////////////////
//LOOP
void loop(){

     if(digitalRead(pirPin) == HIGH){
	 digitalWrite(ledPin, HIGH);   //the led visualizes the sensors output pin state
	 if(lockLow){
	   lockLow = false;		//make sure we wait for a transition to LOW before any further output is made
	   Serial.println("---");
	   Serial.print("motion detected at ");
	   Serial.print(millis()/1000);
	   Serial.println(" sec");
	   delay(50);
	   }
	   takeLowTime = true;
	 }

     if(digitalRead(pirPin) == LOW){
	 digitalWrite(ledPin, LOW);  //the led visualizes the sensors output pin state

	 if(takeLowTime){
	  lowIn = millis();	    //save the time of the transition from high to LOW
	  takeLowTime = false;	 //make sure this is only done at the start of a LOW phase
	  }

	 if(!lockLow && millis() - lowIn > pause){  //if the sensor is low for more than the given pause, we assume that no more motion is going to happen
	     lockLow = true;				//makes sure this block of code is only executed again after a new motion sequence has been detected
	     Serial.print("motion ended at ");	//output
	     Serial.print((millis() - pause)/1000);
	     Serial.println(" sec");
	     delay(50);
	     }
	 switch(digitalRead(pirPin) == HIGH){
 
   case 1:
     playcomplete("01NEVE~1.WAV");  
    
 }
     }}

        
 
 void playcomplete(char *name) {
 playfile(name);
 while (wave.isplaying);
 card.close_file(f);
}

void playfile(char *name) {
 // stop any file already playing
 if (wave.isplaying) {
   wave.stop();
   card.close_file(f);
 }

 f = card.open_file(name);
 if (f && wave.create(f)) {
   wave.play();
 }
 

  }