# Babel Fish

## Overview

https://www.youtube.com/watch?v=l6MIZbZ27ZM

Learn to make a speaking, card-reading toy! The Babel Fish helps you learn to say words and phrases on RFID flash cards by reading the card and playing an associated sound file loaded on an SD card inside. This project is very straightforward and could make a great jumping-off point for your own awesome RFID and Wave Shield project!

![](https://cdn-learn.adafruit.com/assets/assets/000/001/445/medium800/rfid___nfc_babel-fish-adafruit.jpg?1396772166)

For this project you will need

- [Arduino Uno](http://www.adafruit.com/product/50)
- [Adafruit NFC/RFID Shield](http://www.adafruit.com/product/789)
- [Adafruit Wave Shield](http://www.adafruit.com/product/94) (and your own SD card & speaker) or [Wave shield starter kit](http://www.adafruit.com/product/175)
- [MiFare cards (one per flashcard)](http://www.adafruit.com/product/359)
- [Power adapter](http://www.adafruit.com/product/63)

# Babel Fish

## Make the NFC/RFID Shield

https://www.youtube.com/watch?v=WgLV5X1iWWw

Watch our video about the [NFC/RFID shield for Arduino](http://learn.adafruit.com/adafruit-pn532-rfid-nfc)! We need to modify the shield to work with the Wave Shield.

![](https://cdn-learn.adafruit.com/assets/assets/000/001/459/medium800/rfid___nfc_Screen_Shot_2012-08-01_at_6.23.03_PM.png?1396772350)

Use a utility knife to cut the connection between the IRQ pin and header pin neighbor.

![](https://cdn-learn.adafruit.com/assets/assets/000/001/460/medium800/rfid___nfc_Screen_Shot_2012-08-01_at_6.23.41_PM.png?1396772431)

Solder a wire from the IRQ pin to digital pin 6.

# Babel Fish

## Make the Wave Shield

![](https://cdn-learn.adafruit.com/assets/assets/000/001/461/medium800/rfid___nfc_Screen_Shot_2012-08-01_at_6.27.09_PM.png?1396772537)

Refer to the [Wave Shield tutorial](http://learn.adafruit.com/adafruit-wave-shield-audio-shield-for-arduino) for complete instructions for assembly. Use the instructed wiring like in the sample. Test the shield to be sure it works before combining with another shield.

# Babel Fish

## Flash cards

![](https://cdn-learn.adafruit.com/assets/assets/000/001/462/medium800/rfid___nfc_Screen_Shot_2012-08-01_at_6.28.51_PM.png?1396772644)

You can make flash cards by printing our words and phrases and taping them to RFID cards.

![](https://cdn-learn.adafruit.com/assets/assets/000/001/463/medium800/rfid___nfc_Screen_Shot_2012-08-01_at_6.29.26_PM.png?1396772743)

You can also just write on the RFID cards with a dry-erase marker.

# Babel Fish

## Programming

Program your Arduino with the following sketch and open the serial monitor.  
  
Dont forget you'll need to have the Waveshield WaveHC library, and NFCshield library installed first. Visit the Wave and NFC shield product pages and test both of them before continuing onto this code!

```auto
#include <WaveHC.h>
#include <WaveUtil.h>
#include <Wire.h>
#include <Adafruit_NFCShield_I2C.h>


#define IRQ 6 // this trace must be cut and rewired!
#define RESET 8

Adafruit_NFCShield_I2C nfc(IRQ, RESET);

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 for a pi digit or period
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))

//////////////////////////////////// SETUP

void setup() {
  // set up Serial library at 9600 bps
  Serial.begin(9600);
  
  PgmPrintln("Pi speaker");
  
  if (!card.init()) {
    error("Card init. failed!");
  }
  if (!vol.init(card)) {
    error("No partition!");
  }
  if (!root.openRoot(vol)) {
    error("Couldn't open dir");
  }

  PgmPrintln("Files found:");
  root.ls();
  
  // find Adafruit RFID/NFC shield
  nfc.begin();

  uint32_t versiondata = nfc.getFirmwareVersion();
  if (! versiondata) {
    Serial.print("Didn't find PN53x board");
    while (1); // halt
  }
  // Got ok data, print it out!
  Serial.print("Found chip PN5"); Serial.println((versiondata>>24) & 0xFF, HEX);
  Serial.print("Firmware ver. "); Serial.print((versiondata>>16) & 0xFF, DEC);
  Serial.print('.'); Serial.println((versiondata>>8) & 0xFF, DEC);
  
  // configure board to read RFID tags
  nfc.SAMConfig();

}

/////////////////////////////////// LOOP

unsigned digit = 0;

void loop() {
  uint8_t success;
  uint8_t uid[] = { 0, 0, 0, 0, 0, 0, 0 }; // Buffer to store the returned UID
  uint8_t uidLength; // Length of the UID (4 or 7 bytes depending on ISO14443A card type)

  // wait for RFID card to show up!
  Serial.println("Waiting for an ISO14443A Card ...");

    
  // Wait for an ISO14443A type cards (Mifare, etc.). When one is found
  // 'uid' will be populated with the UID, and uidLength will indicate
  // if the uid is 4 bytes (Mifare Classic) or 7 bytes (Mifare Ultralight)
  success = nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, uid, &uidLength);

  uint32_t cardidentifier = 0;
  
  if (success) {
    // Found a card!

    Serial.print("Card detected #");
    // turn the four byte UID of a mifare classic into a single variable #
    cardidentifier = uid[3];
    cardidentifier <<= 8; cardidentifier |= uid[2];
    cardidentifier <<= 8; cardidentifier |= uid[1];
    cardidentifier <<= 8; cardidentifier |= uid[0];
    Serial.println(cardidentifier);

  // repeat this for loop as many times as you have RFID cards
    if (cardidentifier == 2588581390) { // this is the card's unique identifier
      playcomplete("1.WAV"); // these are file names for the sample audio files - change them to your own file names
    }
  
    if (cardidentifier == 2146122274) {
      playcomplete("2.WAV");
    }
  }
}

/////////////////////////////////// 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
*/
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);
}
/*
* Play a file and wait for it to complete
*/
void playcomplete(char *name) {
  playfile(name);
  while (wave.isplaying);
  
  // see if an error occurred while playing
  sdErrorCheck();
}
/*
* Open and start playing a WAV file
*/
void playfile(char *name) {
  if (wave.isplaying) {// already playing something, so stop it!
    wave.stop(); // stop it
  }
  if (!file.open(root, name)) {
    PgmPrint("Couldn't open file ");
    Serial.print(name);
    return;
  }
  if (!wave.create(file)) {
    PgmPrintln("Not a valid WAV");
    return;
  }
  // ok time to play!
  wave.play();
}
```

Replace the long number in the following for loop with your RFID card's ID. Replace the sound file name with the filename for your chosen sound samples.

```auto
    if (cardidentifier == 2146122274) {
      playcomplete("2.WAV");
    }
```

# Babel Fish

## Fish Box

Mark and cut the box with holes for the RFID antenna, speaker, and power cable.

![](https://cdn-learn.adafruit.com/assets/assets/000/001/464/medium800/rfid___nfc_Screen_Shot_2012-08-01_at_6.31.11_PM.png?1396772821)

Coat a plain cardboard box in glitter Mod Podge.

![](https://cdn-learn.adafruit.com/assets/assets/000/001/465/medium800/rfid___nfc_Screen_Shot_2012-08-01_at_6.31.20_PM.png?1396772894)

The Mod Podge also works as an adhesive! Use it to attach eyes (google image search) and fins (yellow file folder).

![](https://cdn-learn.adafruit.com/assets/assets/000/001/466/medium800/rfid___nfc_Screen_Shot_2012-08-01_at_6.31.28_PM.png?1396772985)

Once dry, assemble the box and install the electronics.

![](https://cdn-learn.adafruit.com/assets/assets/000/001/467/medium800/rfid___nfc_Screen_Shot_2012-08-01_at_6.31.39_PM.png?1396773062)

Using a stretchy scrap of fabric, stitch the speaker in place with yarn and a yarn needle. This is a good temporary speaker mount you can easily undo later and is recommended over hot glue!

# Babel Fish

## Use it!

![](https://cdn-learn.adafruit.com/assets/assets/000/001/458/medium800/rfid___nfc_P7311425.jpg?1396772273)

You can reprogram your sketch for new words and phrases any time!


## Featured Products

### Adafruit METRO 328 Fully Assembled - Arduino IDE compatible

[Adafruit METRO 328 Fully Assembled - Arduino IDE compatible](https://www.adafruit.com/product/50)
We sure love the ATmega328 here at Adafruit, and we use them&nbsp;_a lot_&nbsp;for our own projects. The processor has plenty of GPIO, Analog inputs, hardware UART SPI and I2C, timers and PWM galore - just enough for most simple projects. When we need to go small, we use a <a...></a...>

Out of Stock
[Buy Now](https://www.adafruit.com/product/50)
[Related Guides to the Product](https://learn.adafruit.com/products/50/guides)
### Adafruit PN532 NFC/RFID Controller Shield for Arduino + Extras

[Adafruit PN532 NFC/RFID Controller Shield for Arduino + Extras](https://www.adafruit.com/product/789)
We've taken our popular Adafruit PN532 breakout board and turned it into a shield - the perfect tool for any 13.56MHz RFID or NFC application. The Adafruit NFC shield uses the PN532 chip-set (the most popular NFC chip on the market) and is what is embedded in pretty much every phone or...

Out of Stock
[Buy Now](https://www.adafruit.com/product/789)
[Related Guides to the Product](https://learn.adafruit.com/products/789/guides)
### Adafruit Wave Shield for Arduino Kit

[Adafruit Wave Shield for Arduino Kit](https://www.adafruit.com/product/94)
Adding quality audio to an electronic project is surprisingly difficult. Here is a shield for Arduino 328's that solves this problem. It can play up to 22KHz 12bit uncompressed audio files of any length. It's low cost, available as an easy-to-make kit. It has an onboard DAC, filter and...

Out of Stock
[Buy Now](https://www.adafruit.com/product/94)
[Related Guides to the Product](https://learn.adafruit.com/products/94/guides)
### Music & sound add-on pack for Arduino

[Music & sound add-on pack for Arduino](https://www.adafruit.com/product/175)
Its a Wave shield party pack! Just add an Arduino to create your own iPod-killer, audio art, sound-effects box...

Comes with:

- Latest [Wave shield kit](http://www.adafruit.com/products/94), works with more SD cards and with older NG Arduinos! Unassembled
- 8 GB...

Out of Stock
[Buy Now](https://www.adafruit.com/product/175)
[Related Guides to the Product](https://learn.adafruit.com/products/175/guides)
### 9 VDC 1000mA regulated switching power adapter - UL listed

[9 VDC 1000mA regulated switching power adapter - UL listed](https://www.adafruit.com/product/63)
This is a really nice power supply. It's a switching DC supply so it's small and light and efficient. It is thin so it fits in power strips without blocking other outlets. The output is regulated so you'll get a steady 9V up to 1000mA (1 Amp) of current draw. 5.5mm/2.1mm barrel...

In Stock
[Buy Now](https://www.adafruit.com/product/63)
[Related Guides to the Product](https://learn.adafruit.com/products/63/guides)
### 13.56MHz RFID/NFC Card - Classic 1K

[13.56MHz RFID/NFC Card - Classic 1K](https://www.adafruit.com/product/359)
This is a blank 13.56MHz RFID/NFC card - often used for train/bus passes but also found in other systems where a proximity card is desired. The tag contains a small RFID chip and an antenna, and is passively powered by the reader/writer when placed a couple inches away.  
  
These can be...

In Stock
[Buy Now](https://www.adafruit.com/product/359)
[Related Guides to the Product](https://learn.adafruit.com/products/359/guides)

## Related Guides

- [OLED TRON Clock](https://learn.adafruit.com/oled-tron-clock.md)
- [Smart Measuring Cup](https://learn.adafruit.com/smart-measuring-cup.md)
- [Arduino Prototyping Mounting Plate](https://learn.adafruit.com/arduino-prototyping-mounting-plate.md)
- [2.8" TFT Touch Shield](https://learn.adafruit.com/2-8-tft-touch-shield.md)
- [Arduino Lesson 7. Make an RGB LED Fader](https://learn.adafruit.com/adafruit-arduino-lesson-7-make-an-rgb-led-fader.md)
- [All About Arduino Libraries](https://learn.adafruit.com/adafruit-all-about-arduino-libraries-install-use.md)
- [Analog Feedback Servos](https://learn.adafruit.com/analog-feedback-servos.md)
- [Bluetooth Controlled Motorized Camera Slider](https://learn.adafruit.com/bluetooth-motorized-camera-slider.md)
- [2.2" TFT Display](https://learn.adafruit.com/2-2-tft-display.md)
- [Ladyada's Learn Arduino - Lesson #2](https://learn.adafruit.com/ladyadas-learn-arduino-lesson-number-2.md)
- [Halloween Pumpkin](https://learn.adafruit.com/halloween-pumpkin.md)
- [Naughty or Nice Machine](https://learn.adafruit.com/naughty-or-nice-machine.md)
- [Collin's Lab: RFID](https://learn.adafruit.com/collins-lab-rfid.md)
- [A REST API for Arduino & the CC3000 WiFi Chip](https://learn.adafruit.com/a-rest-api-for-arduino-and-the-cc3000-wifi-chip.md)
- [Arduin-o-Phone](https://learn.adafruit.com/arduin-o-phone-arduino-powered-diy-cellphone.md)
