The Mateo Dishwasher – Stupid Pet Trick

 

We’ve had a huge problem in the IM lab of people not washing their dishes. We’ve tried just telling people to wash their dishes but that does not seem to work, so we needed to resort to moreĀ creative solutions.

Introducing, the Mateo dishwasher:

It’s the machine that shames people into washing their dishes using Mateo’s angry and shaming voice. You can’t hear this and not reevaluate your life choices that lead you up to this point. However, Mateo is forgiving if you come back to do your dishes:

 

I am using the Adafruit MP3 shield for this and playing the sounds from an SD card, with an external amplifier between the shield and the speaker in order to make the sound louder.

Here’s the code:

// include SPI, MP3 and SD libraries
#include <SPI.h>
#include <Adafruit_VS1053.h>
#include <SD.h>

// These are the pins used for the breakout example
#define BREAKOUT_RESET  9      // VS1053 reset pin (output)
#define BREAKOUT_CS     10     // VS1053 chip select pin (output)
#define BREAKOUT_DCS    8      // VS1053 Data/command select pin (output)
// These are the pins used for the music maker shield
#define SHIELD_RESET  -1      // VS1053 reset pin (unused!)
#define SHIELD_CS     7      // VS1053 chip select pin (output)
#define SHIELD_DCS    6      // VS1053 Data/command select pin (output)

// These are common pins between breakout and shield
#define CARDCS 4     // Card chip select pin
// DREQ should be an Int pin, see http://arduino.cc/en/Reference/attachInterrupt
#define DREQ 3       // VS1053 Data request, ideally an Interrupt pin

Adafruit_VS1053_FilePlayer musicPlayer =
  // create breakout-example object!
  //  Adafruit_VS1053_FilePlayer(BREAKOUT_RESET, BREAKOUT_CS, BREAKOUT_DCS, DREQ, CARDCS);
  // create shield-example object!
  Adafruit_VS1053_FilePlayer(SHIELD_RESET, SHIELD_CS, SHIELD_DCS, DREQ, CARDCS);

int sensorpin = A1;
int currenttime = 0;
int triggertime = 0;

void setup() {
  Serial.begin(9600);
  Serial.println("Adafruit VS1053 Simple Test");

  if (! musicPlayer.begin()) { // initialise the music player
    Serial.println(F("Couldn't find VS1053, do you have the right pins defined?"));
    while (1);
  }
  Serial.println(F("VS1053 found"));

  if (!SD.begin(CARDCS)) {
    Serial.println(F("SD failed, or not present"));
    while (1);  // don't do anything more
  }

  musicPlayer.setVolume(1, 1);

  // If DREQ is on an interrupt pin (on uno, #2 or #3) we can do background
  // audio playing
  musicPlayer.useInterrupt(VS1053_FILEPLAYER_PIN_INT);  // DREQ int
//  musicPlayer.sineTest(0x44, 500);
}
int cutoff = 250;
void loop() {
  currenttime = millis();
  int x = analogRead(sensorpin);
  //  Serial.println(x);
  if (x > cutoff && (currenttime - triggertime) > 2000) {
    musicPlayer.playFullFile("greatjob.mp3");

    //    delay(100);
    if (analogRead(sensorpin) > cutoff) {
      triggertime = millis();
      return;
    } else {
      musicPlayer.playFullFile("heyhey.mp3");
      if (analogRead(sensorpin) > cutoff) {
        musicPlayer.playFullFile("right.mp3");
        triggertime = millis();
        return;
      }
      musicPlayer.playFullFile("comeback.mp3");
      if (analogRead(sensorpin) > cutoff) {
        musicPlayer.playFullFile("right.mp3");
        triggertime = millis();
      } else {
        musicPlayer.playFullFile("insult.mp3");
        triggertime = millis();
        return;
      }
    }
  }
}

 

Leave a Reply

Your email address will not be published. Required fields are marked *