Introduction: HKU ITTT - Joke Generator

This is a project I did at HKU that required us to make a device with the Arduino Uno. In my case I wanted to do something with the fact that my sense of humor is somewhere below sealevel and the fact that quite a few people somehow still laugh at it.

And that is how the Joke Generator was born.

Step 1: Step 1: the Arduino and the Breadboard

Basically, this is what they should look like. The little led-light is optional.

Step 2: Step 2: Standard Firmata and Minim

You now want to make sure that the StandardFirmata.ino is on the Arduino. In processing you'll want to import the Firmata library as well, along with the Minim one.

Step 3: Step 3: Code.

Throw this wicked stuff into processing. Obviously replace the filenames with the names of your own files. Unless you are into terrible Dutch puns. If that is the case then by all means go right ahead.

import processing.serial.*;
import cc.arduino.*;

import ddf.minim.*; import ddf.minim.analysis.*;

Arduino arduino; Minim minim; AudioPlayer kutGrap1; ArrayList kutGrappen = new ArrayList(); boolean button;

void setup() { println(Arduino.list()); arduino = new Arduino(this, Arduino.list()[0], 57600); minim = new Minim(this); arduino.pinMode(7, Arduino.INPUT_PULLUP); arduino.pinMode(13, Arduino.OUTPUT); kutGrappen.add(minim.loadFile("fleace.mp3", 2048)); kutGrappen.add(minim.loadFile("magnetronderwijs.mp3", 2048)); kutGrappen.add(minim.loadFile("ontsnappel.mp3", 2048)); kutGrappen.add(minim.loadFile("tree.mp3", 2048)); kutGrappen.add(minim.loadFile("katastrofe.mp3", 2048)); kutGrappen.add(minim.loadFile("aardblij.mp3", 2048)); kutGrappen.add(minim.loadFile("bij.mp3", 2048)); kutGrappen.add(minim.loadFile("dolfijn.mp3", 2048)); kutGrappen.add(minim.loadFile("ethiopie.mp3", 2048)); kutGrappen.add(minim.loadFile("fan.mp3", 2048)); kutGrappen.add(minim.loadFile("fleace.mp3", 2048)); kutGrappen.add(minim.loadFile("hugoboss.mp3", 2048)); kutGrappen.add(minim.loadFile("islaminaat.mp3", 2048)); kutGrappen.add(minim.loadFile("kippenbouten.mp3", 2048)); kutGrappen.add(minim.loadFile("lepra.mp3", 2048)); kutGrappen.add(minim.loadFile("licht.mp3", 2048)); kutGrappen.add(minim.loadFile("nest.mp3", 2048)); kutGrappen.add(minim.loadFile("paws.mp3", 2048)); kutGrappen.add(minim.loadFile("Sin.mp3", 2048)); kutGrappen.add(minim.loadFile("kutlachje.mp3", 2048)); kutGrappen.add(minim.loadFile("kutlachje.mp3", 2048)); kutGrappen.add(minim.loadFile("kutlachje.mp3", 2048)); kutGrappen.add(minim.loadFile("kutlachje.mp3", 2048)); kutGrappen.add(minim.loadFile("kutlachje.mp3", 2048)); kutGrappen.add(minim.loadFile("transparent.mp3", 2048)); kutGrappen.add(minim.loadFile("tree.mp3", 2048)); kutGrappen.add(minim.loadFile("tumor.mp3", 2048)); kutGrappen.add(minim.loadFile("vislamiet.mp3", 2048)); kutGrappen.add(minim.loadFile("voetzoolvergiftiging.mp3", 2048)); }

void draw() { if(arduino.digitalRead(7) == Arduino.LOW) { arduino.digitalWrite(13, Arduino.HIGH); if (button == false) { int welkeGrap = int(random(0,kutGrappen.size())); print(welkeGrap); AudioPlayer kutGrap = kutGrappen.get(welkeGrap); kutGrap.rewind();; button = true; } } else { arduino.digitalWrite(13, Arduino.LOW); button = false; } }

Step 4: Step 4: Profit.

If I'm not mistaken you are now done. As you can clearly tell, this project is rather barebones. Feel free to knit your Arduino a hilarious little sweater or something.