Instructables
Goal:  To get my fridge to say incredibly rude and abusive things when it opens.  We could use, Ping, PIR, Hack the Plunger already in use.  But a photocell seems the cheapest and easiest triggering mechanism.   How do you like my project case?

Parts:   

Arduino Uno
Adafruit Wave shield
Photocell
Perf board
9volt battery
Styrofoam project case
Solo lid
10k resistor
some wire
SD card


Links:
 

http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1233246215 Cool Library
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1239997017  Helpful code
http://www.instructables.com/id/Photocell-tutorial/  LadyAda tutorial for Photocell
http://www.ladyada.net/make/waveshield/use.html WaveShield Turtorial
http://www2.research.att.com/~ttsweb/tts/demo.php The rude british girl

Pudding it together:

Place wave shield on Arduino.  Wire up the photocell on a separate board as per the tutorial.   We're going to read the results between a pull-down resistor and 5volt.  Cram it in a case.  I'm stuck in a hotel with little money or resources.  But I still found a Project Case.   @Engineers who make amazing things and leave wires everywhere-try putting it in a case, ur wires are lame.   Test it out,  and mess with your room-mates.  They'll be shocked when the British lady in the fridge starts calling them out on their idiosyncrasies.   I know rudeness doesn't exactly fit into the Instructables paradigm but no one will actually see this unless it gets featured.   So whatevs man.   All the really offensive stuff I left for the last page.  
 

 

Step 1: Code


#include <AF_Wave.h> //You will need the AF Wave library
#include <avr/pgmspace.h>
#include "util.h"
#include "wave.h"

AF_Wave card;
File f;
Wavefile wave;

#define redled 9

uint16_t samplerate;

int Power = 19;

void setup() {
Serial.begin(9600); // set up Serial library at 9600 bps
Serial.println("Wave test!");

randomSeed(analogRead(0));

pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(redled, OUTPUT);
pinMode(Power, OUTPUT);

if (!card.init_card()) {
putstring_nl("Card init. failed!"); return;
}
if (!card.open_partition()) {
putstring_nl("No partition!"); return;
}
if (!card.open_filesys()) {
putstring_nl("Couldn't open filesys"); return;
}

if (!card.open_rootdir()) {
putstring_nl("Couldn't open dir"); return;
}

putstring_nl("Files found:");
ls();
}

void ls() {
char name[13];
int ret;

card.reset_dir();
putstring_nl("Files found:");
while (1) {
ret = card.get_next_name_in_dir(name);
if (!ret) {
card.reset_dir();
return;
}
Serial.println(name);
}
}

uint8_t tracknum = 0;

void loop() {
int sensor = 0;
int sensorPin = 0;
sensor = analogRead(sensorPin);
uint8_t i, r;
char c, name[15];


card.reset_dir();
// scroll through the files in the directory

//------------------------------------------------
// THIS IS THE BUTTON IF STATEMENT!!!!
//

digitalWrite(Power, LOW); //This turns the Speaker system
//Off using a powerSwitchTail relay
// when no music is playing.
// You don't need this if you
// want to leave your speakers on

if (sensor > 500){ // 300 is for the IR distance sensor,
// you can change that number depending
// on the type of sensor you use.
// This sensor is on pin Analog 0.

digitalWrite(Power, HIGH); //This turns the speakers ON using
//the powerswitchtail Relay
for (i=0; i<tracknum+1; i++) {
r = card.get_next_name_in_dir(name);
if (!r) {
// ran out of tracks! start over
tracknum = 0;
return;
}
}
putstring("\n\rPlaying "); Serial.print(name);
// reset the directory so we can find the file
card.reset_dir();
playcomplete(name);

tracknum++;
}
}
void playcomplete(char *name) {
uint16_t potval;
uint32_t newsamplerate;

playfile(name);
samplerate = wave.dwSamplesPerSec;
while (wave.isplaying); {
// you can do stuff here!
delay(500);
}
card.close_file(f);
delay(30000);
}

void playfile(char *name) {
f = card.open_file(name);
if (!f) {
putstring_nl(" Couldn't open file"); return;
}
if (!wave.create(f)) {
putstring_nl(" Not a valid WAV"); return;
}
// ok time to play!
wave.play();
}

    
I hate when people just attach their code, it always tries to download as a .tmp file and that just seem sketchy to me.  Too many smart people on this site to be downloading random files.     

Step 2: Adult Content Ahead

Picture of Adult Content Ahead
We'll be using *naughty* words.  This fridge is abusive.  Consider urself warned.   I've got alot of wave files on this SD card.  Most are from ATT but you could convert anything you might want to record.  ATT limits the speech synth to 300 character or about 23 seconds.  I should have put a delay between the photocell and playcomplete(name) functions.  But I'm lazy and don't want to now.  



And another, we have to wait cuz of the delay, explained in the first video.


Where Does Mayo Come From?


 
 
Remove these adsRemove these ads by Signing Up
Actually, everyone will see this now it's been linked on Hackaday.com ^_^
Grissini (author)  scarabdrowner3 years ago
I know, these apples taste like the Pink Lady variety. So delicious. Muuh hahaha
Grissini (author) 3 years ago
The last video is by far the best, be sure to check it out if this interested you. The true nature of my device; Mean, Rude and Offensive. But due to the "be nice" policy, I kept it much cleaner than it really is. My device is not nice. Not everything in this world is. Or should be.