2.00b Toy Product Design

Let's Play - Toobers!

Electronics 5Breadboard Prototype

Four Buttons and Four LEDs

It's time to kick it up a notch! We'll be hooking up all four of the LEDs and buttons now (red, green, blue, and yellow). You can, of course, pick your own colors for the buttons and the LEDs if you like.

For this, we'll be using Pins 2 - 9 on the Arduino. The pinouts are as follows:

Pin 2 Red LED Output
Pin 3 Green LED Output
Pin 4 Blue LED Output
Pin 5 Yellow LED Output
Pin 6 Red Button Input
Pin 7 Green Button Input
Pin 8 Blue Button Input
Pin 9 Yellow Button Input

If you think you understand how you built the red LED and button, see if you can duplicate this setup 3 times. If you don't feel comfortable yet, don't worry - keep reading for a handy guide!

Your result should look something like this:

In this photo, we used different colored wires, just to make it easier to identify. You can ask around for different colors of wire (we always have plenty extra). You can also use the jumper wires we provided you to save yourself some time when it comes to stripping wires.

And yes! you can peel them apart to separate them.

If you'd like, you're free to follow the pin markings below to get to build your circuit so it's identical to ours.

Green

(everything is shifted 6 from red)

  • LED Arduino Output to Breadboard PIN 3 to J9
  • Button Arduino Button to Breadboard PIN 7 to J8
  • LED Long end to Arduino Output and short end to resistor H9 to H10
  • 220Ω Resistor to connect LED to Ground G10 to E10
  • Short wire to bring Input to button G8 to E8
  • Button from wire to ground C8 to C10
  • Wire to ground A10 to GND

Blue

(everything is shifted 6 from green)

  • LED Arduino Output to Breadboard PIN 4 to J15
  • Button Arduino Button to Breadboard PIN 8 to J14
  • LED Long end to Arduino Output and short end to resistor H15 to H16
  • 220Ω Resistor to connect LED to Ground G16 to E16
  • Short wire to bring Input to button G14 to E14
  • Button from wire to ground C14 to C16
  • Wire to ground A16 to GND

Yellow

(everything is shifted 6 from blue)

  • LED Arduino Output to Breadboard PIN 5 to J21
  • Button Arduino Button to Breadboard PIN 9 to J20
  • LED Long end to Arduino Output and short end to resistor H21 to H22
  • 220Ω Resistor to connect LED to Ground G22 to E22
  • Short wire to bring Input to button G20 to E20
  • Button from wire to ground C20 to C22
  • Wire to ground A22 to GND

Software for our Four New Friends

It's always good to test your wiring in stages. Once you have a lot of wires, it can be difficult to find what's wrong if there's a lot going on. For this, we've prepared a short demo file which will help you test to see if you've got all the LEDs and buttons wired up correctly.

Take a quick look at the code before uploading it. Without reading further (or watching the video below), take a guess at what might happen. Upload the code to the Arduino!

The expected behavior should be: each time you press a button, that button lights up and stays on, while all other buttons go off.

And Finally, Some Sound

Wow, it's been really quiet here. Let's add some sound to our toy! For sound, the Arduino will need to rely on an external chip to play audio. The storage on an Arduino is very limited (usually around 32k bytes) and so we need a device that can store and play audio files when the Arduino wants it to. Introducing the DFPlayer!

The pin out diagram for the DFPlayer looks like the below:

While the DFPlayer has many different modes of operation, (some of which are standalone and don't require an Arduino), we'll be using the TX and RX pins on the DFPlayer (transmit and receive, respectively), to communicate with the DFPlayer.

The DFPlayer pulls .mp3 files from a microSD card. The specific naming convention depends on the mode you're using it in. We've preloaded your microSD card with sounds so that it'll work with the Toobers game.

The microSD card only goes in one orientation, and to remove it, simply push the microSD card in once for it to spring back out (known as a push-push mechanism or a catch/latch in mechanical design)

Putting Everything Together

It's time to put everything together! While this schematic may look intimidating, we've already done a good chunk of it. The final piece is to attach the DFplayer and the speaker.

We'll start with placing the DFPlayer. The DFPlayer has two rows of pins, which can straddle the trough nicely to prevent its own pins from shorting (coming into contact) with itself.

  • Orient the DFplayer so the microSD card is to the left, and place the bottom left pin so it's on B29.
  • Connect the DFplayer ground to the ground bus A30 to gnd
  • Connect the DFplayer power to the power bus J36 to 5v
  • Connect the Arduino Pin 10 to the DFPlayer TX pin PIN 10 to J34
  • Connect the 1kΩ resistor to the DFPlayer RX pin (to help reduce noise) I27 to I35
  • Add a wire to connect to the Arduino J27 to PIN 11

Next, we want to connect a mini speaker which will actually be what's playing the sound. The speaker is connected directly to the DFPlayer. Take a look at your speaker, and note down which end it has (on the left are header connectors, and on the right are JST connectors (PH variant))

For prototyping purposes, we can insert a solid-core wire into the ends of both of these (see below) to connect them to the breadboard.

When completed, you should have something that looks like the image below.

  • Connect the red wire of the speaker to the DFPlayer Speaker Pin 1 (Speaker red to J31)
  • Connect the black wire of the speaker to the DFPlayer Speaker Pin 2 (Speaker black to J29)

And that's it for the wiring! And finally, it's time to upload the final Toobers code, which should play the entire Toobers game.

When you upload this file, your Arduino should immediately come to life and start playing the Toobers start up sound. If it doesn't, double check your wiring. If the sound plays, and all the buttons are working, CONGRATULATIONS! You have your first Toobers prototype! Give yourself a pat on the back. You deserve it.

If something doesn't look right, here are some steps that may help you debug:

No audio is playing:

  • Double check your wiring near the DFPlayer. Ensure that they're actually connected to the right pin of the DFPlayer.
  • Ensure that the microSD card is actually in the DFPlayer.

If the wrong files are playing:

  • Talk to a lab staff regarding re-loading audio files onto your microSD card. The issue may be the dotfiles as mentioned below.

An LED isn't turning on:

  • Double check your wiring for the LED (and if it's just a specific one, see if you can find a difference between that LED and another LED that is working.
  • Make sure the LED isn't burnt out. Did you remember to put in your resistor?
  • Is the orientation of the LED correct?
  • What happens if you try a different LED?
  • You can always upload the old code (FourNewFriends.ino) to test just your LED setup, and go back to the previous step.

A Button isn't working:

  • It's sometimes hard to see where the contacts are- double check to make sure the contacts are indeed seated where they're supposed to be.
  • Is it just that button? What happens if you try a different button?
  • Similarly to the LED test, you can always upload the old code (FourButtonFriends.ino) to test just the malfunctioning button.

Play around with your prototype for a bit. Bask in the glory. See how high of a score you can get. Exciting, isn't it?

Now it's your turn!

If you're reached this step, it's time to try creating your own four button and four LED game! This is an optional activity, as we understand everyone's programming and electronics experience may vary.

Attempt programming your game based on the inputs and outputs you have. Feel free to be creative! Upload your own audio files, and see what you can do with the platform you've created. What about a reaction based game? Could you make something that's two players? Four? The possibilities are endless!

The Arduino ecosystem is designed to be easy to learn, and it provides plenty of resources to teach yourself how to program. Some ideas if you'd like to learn more:

  • If you learn best by example, check out some of the example code built into the Arduino IDE by going to
    File → Example
  • If you prefer a more structured approach, check out some of Adafruit's online lessons. Adafruit is a great resource for learning electronics (and the founder is an MIT alum!)
  • Visit the Arduino Reference page which has helpful functions

Additionally, when working with the DFPlayer, you should consult this wiki page. Notably, on a Mac, when files are dragged to a SD card, dotfiles are created, so you should use the dot_clean command (as mentioned in the wiki) to clear any ghost files. The specific library we're using can be found on the DFRobot GitHub.

If you need a microSD card reader to upload your own sound files, the lab/staff members have them. You can view how we've currently mapped the sound files for the existing Toobers game.

Have a specific idea you want to implement but don't know how? We're happy to help! Talk to your instructor, mentor, anyone in a lab coat, or reach out to ask-the-tas.

If you've made something you're especially happy with, submit it to us! We'll showcase the top few on the 2.00b site for other students to download, and you might even win a prize ;) This is a completely optional activity.

The zip file should contain:

  • Any Arduino Sketch files (.ino)
  • Any audio files needed for your game
  • A text file or Word document containing your name and your email (so we know who to credit!)

Please have your game submitted (if you choose to submit one) by Feb 20.

Ideate some Housing Designs!

This is also an optional activity, which we'll focus on more in the next lab. Take a few moments and sketch (in your notebook) some concepts for your customized Toobers Toy! While you haven't been given the constraints yet (i.e. size, dimensions) a quick sketch can always inspire something later!

Coming up next...

Next lab, we'll be working on soldering the components onto a printed circuit board (PCB) and designing a housing for our Toobers toy in Fusion360. Take your kits with you, but be sure to bring it back for next lab.