Introduction: Rebecca's Outfit

Rebecca’s Outfit is a running accessory designed to motivate the runner to keep a fast pace by subjecting him/her to horrendous music. Rebecca’s Outfit will play a song on the annoyance level of Rebecca Black’s “Friday”; if the runner is running fast, the song will play faster than the normal playback rate, and if the runner is standing still, the song will play slower than the normal playback rate. If the runner wants the song to be over more quickly (and also sound more hilarious) he/she will surely be motivated to keep running at a fast pace.

An additional component is a pair of sunglasses with a row of LEDs on top. The LEDs will blink with increasing frequency as the runner’s speed increases.

This is accomplished by an Arduino with a Wave Shield to play music, and an accelerometer to calculate the speed of the runner.

Step 1: Materials List

Arduino (we used the Uno SMD, but theoretically you could use another)
Wav Shield http://www.ladyada.net/make/waveshield/
Accelerometer http://datasheet.octopart.com/MMA1260EG-Freescale-Semiconductor-datasheet-142002.pdf
Soldering supplies
Wires
Headphones/speaker
12 volt battery
SD card
old sunglasses
Velcro
on/off switch
Hot glue

Step 2: Arduino Hardware

1. Put together the Wave Shield according to the instructions on the website (http://www.ladyada.net/make/waveshield/make.html).

2. Put the accelerometer on a breakout board.

3. Connect the accelerometer by soldering wires to the proper pins on the shield - 5 volts power to pin 6, ground to pin 7, and analog input 0 to pin 4. It’s probably best to use header pins for stability.

4. Solder a wire long enough to reach from your hip to your face (will be connected to LEDs) to digital pin 7 long enough to reach from your hip to your face (or another digital pin, but you’ll have to change the code).

5. Solder a wire long enough to reach from your hip to your face (will also connect to LEDs) to the ground pin.

6. Plug in the shield to the Arduino.

Step 3: Sunglasses

1. Place a sheet of cardboard behind the sunglasses, and trace out the outline of the top of the sunglasses frames.

2. Cut out the cardboard such that it is a thin (~3/4 inch) strip in the shape of the top of the sunglasses frames.

3. Plug the LEDs into the cardboard, with the long leads on the bottom. You may want to create holes in the cardboard first using a pushpin.

4. Connect the all the long leads together using wires and solder; do the same for the short leads such that they are connected in a line.

5. Connect the long leads to the wire on the Arduino that is connected to +5 volts using solder, and connect the short leads to the wire connected to ground.

6. Place the cardboard on top of the sunglasses and attach it with a layer of hot glue.

Step 4: Power Supply

1. Connect the wires of a 9 volt battery connector to an DC 2.1 mm plug.

2. Put a switch in between one of the wires connected from the battery connector, so that you can turn the power on/off.

3. Plug in the 9 volt battery to the connector, and plug the jack into the Arduino.

Step 5: Speakers (optional)

The Wave Shield provides a Jack 3.5mm plug, so you can plug in any standard headphones or speakers to Rebecca’s Outfit.
Our solution is to hot-glue a speaker to a hat, and just run around with the hat on your head. We really think that’s the best solution, so that you can annoy people around you, and not just yourself.

Step 6: Arduino Code

/* be sure to download the WaveHC library, available here:
* http://www.ladyada.net/make/waveshield/download.html
*
* code modified from http://www.ladyada.net/media/wavshield/SampleRateMod.pde
*
* The orientation of the accelerometer is important for this code to run properly. The
* accelerometer should be roughly parallel to the Arduino, with the volume control on top as the
* device rests on your hip.
*/

#include <WaveHC.h>
#include <WaveUtil.h>

SdReader card; // This object holds the information for the card
FatVolume vol; // This holds the information for the partition on the card
FatReader root; // This holds the information for the volumes root directory
FatReader file; // This object represent the WAV file
WaveHC wave; // This is the only wave (audio) object, since we will only play one at a time

/*
* Define macro to put error messages in flash memory
*/
#define error(msg) error_P(PSTR(msg))

//LED stuff
long interval = 1000;
int ledPin = 7; // the number of the LED pin

int ledState = LOW; // ledState used to set the LED
long previousMillis = 0; // will store last time LED was updated

//////////////////////////////////// SETUP
void setup() {
pinMode(ledPin, OUTPUT);
Serial.begin(9600);
Serial.println("Wave test!");

// try card.init(true) if errors occur on V1.0 Wave Shield
if (!card.init()) {
error("Card init. failed!");
}
// enable optimize read - some cards may timeout
card.partialBlockRead(true);

if (!vol.init(card)) {
error("No partition!");
}
if (!root.openRoot(vol)) {
error("Couldn't open root");
}
putstring_nl("Files found:");
root.ls();
}

// forward declarition
void playcomplete(FatReader &file);

//////////////////////////////////// LOOP
void loop() {
uint8_t i, r;
char c, name[15];
dir_t dir;

root.rewind();
// scroll through the files in the directory
while (root.readDir(dir) > 0) {
// only play .WAV files
if (!strncmp_P((char *)&dir.name[8]. PSTR("WAV"))) continue;

if (!file.open(vol, dir)){
putstring("Can't open ");
printEntryName(dir);
continue;
}
putstring("\n\rPlaying ");
printEntryName(dir);
Serial.println();
playcomplete(file);
file.close();
}
}


/////////////////////////////////// HELPERS
/*
* print error message and halt
*/
void error_P(const char *str)
{
PgmPrint("Error: ");
SerialPrint_P(str);
sdErrorCheck();
while(1);
}
/*
* print error message and halt if SD I/O error, great for debugging!
*/
void sdErrorCheck(void)
{
if (!card.errorCode()) return;
PgmPrint("\r\nSD I/O error: ");
Serial.print(card.errorCode(), HEX);
PgmPrint(", ");
Serial.println(card.errorData(), HEX);
while(1);
}
int16_t lastpotval = 0;
#define HYSTERESIS 3
/*
* play file with sample rate changes
*/

void makeLEDsblink() {
unsigned long currentMillis = millis();
//putstring("currentMillis = "); Serial.println(currentMillis);
//putstring("prevMillis = "); Serial.println(previousMillis);
//putstring("interval = "); Serial.println(interval);
if(currentMillis - previousMillis > interval) {
// save the last time you blinked the LED
previousMillis = currentMillis;

// if the LED is off turn it on and vice-versa:
if (ledState == LOW){
ledState = HIGH; }
else {
ledState = LOW;
}

// set the LED with the ledState of the variable:
digitalWrite(ledPin, ledState);
}
}



void playcomplete(FatReader &file) {
int16_t potval = 450;
uint32_t newsamplerate;
int counter1 = 0;
int counter2 = 0;
int accelValue;

if (!wave.create(file)) {
putstring_nl(" Not a valid WAV"); return;
}
// ok time to play!
wave.play();

while (wave.isplaying) {
makeLEDsblink();
accelValue = analogRead(0);
Serial.println(accelValue);
if (accelValue < 350) {
counter2++;
}
if (counter1 > 30) {
Serial.println(counter2);
potval = (counter2*18) + 450;
counter1 = 0;
counter2 = 0;
}
if ( ((potval - lastpotval) > HYSTERESIS) || ((lastpotval - potval) > HYSTERESIS)) {
putstring("pot = "); Serial.println(potval, DEC);
putstring("tickspersam = "); Serial.print(wave.dwSamplesPerSec, DEC); putstring(" -> ");
newsamplerate = wave.dwSamplesPerSec;
newsamplerate *= potval;
newsamplerate /= 512; // we want to 'split' between sped up and slowed down.
if (newsamplerate > 48000) {
newsamplerate = 48000;
}
if (newsamplerate < 1000) {
newsamplerate = 1000;
}
wave.setSampleRate(newsamplerate);
interval = 7500000/newsamplerate;
putstring("interval = "); Serial.println(potval, DEC); Serial.println(interval);
Serial.println(newsamplerate, DEC);
lastpotval = potval;
}
delay(100);
counter1++;
}
sdErrorCheck();

Step 7: Setup

1. Load the code below onto the Arduino

2. Find your favorite WAV files and load them onto the SD card

3. Plug the SD card into the Wave Shield.

4. Plug the speakers or your favorite headphones into the audio jack

5. Turn the switch on, and make sure the volume knob is turned to an audible level.

About the box:
To contain the Arduino and the battery, we used a custom 3D-printed plastic box, that we clipped to a belt to maintain it on the "runner". You can use any box that is about the right size, or make your own.
We recommend that you attach the arduino (and the accelerometer) to the inside of the box, to avoid it moving and touching the box. We used velcro stickers to attach everything inside the box.