The Abusive Refrigerator
by Grissini in Living > Pranks, Tricks, & Humor
2965 Views, 8 Favorites, 0 Comments
The Abusive Refrigerator
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
https://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.
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.