Advanced

Coding with Squishy Circuits

  • Grades 6-12
  • 45 minute project

Quick answer

Conductive dough can be a sensor. Connect it to an Arduino and squish, stretch or poke the dough: its resistance changes, the Arduino reads the change, and your code turns it into sound or color. Our free coding guide walks through two projects, Squishy Sound and the Squishy RGB LED Controller.

Arduino wiring for Squishy Sound: 5V through a 470 ohm resistor to pin A0 and a dough snake to ground, with a speaker on pin 9
Tap to enlarge. The 470 ohm resistor and the dough share the 5 volts. Squish the dough and the voltage at pin A0 changes.

How dough becomes a sensor

Every piece of conductive dough has resistance, and the resistance changes with its shape: a long, thin piece resists more than a short, thick one. That makes the dough a variable resistor, and you change it with your hands.

An Arduino cannot measure resistance directly, but it can measure voltage. So the dough is paired with a fixed 470 ohm resistor in a voltage divider. The two share the Arduino's 5 volts. When the dough's resistance goes up, it takes a bigger share, and the voltage at the point between them goes up. The Arduino reads that point on an analog pin as a number from 0 to 1023.

New to resistance? Start with What Is Resistance? and Ohm's Law Explained.

Two projects to code

  • Squishy Sound: the Arduino reads the dough and plays a tone through a speaker. Stretch the dough to raise its resistance and the pitch goes up. Squish it back and the pitch drops. You will use variables, analogRead() and tone().
  • Squishy RGB LED Controller: three pieces of dough control the red, green and blue parts of a color LED. Squeeze each one to mix colors, like a giant pixel. You will use pinMode(), if statements and analogWrite(), which uses PWM to dim each color.

The full wiring diagrams and the code for both projects are in the free guide.

Try it with dough

Build Squishy Sound

This project needs an Arduino and a few electronics parts. Download the guide for the full code and wiring diagram.

You need

  • Arduino Uno (or similar) and USB cable
  • Computer with the Arduino software
  • Conductive (salty) play dough
  • 470 ohm resistor
  • Small speaker (the buzzers from the kits will not work for this project)
  • Breadboard and jumper wires

Steps

  1. Connect the Arduino's 5V pin to one end of the 470 ohm resistor.
  2. Connect the other end of the resistor to analog pin A0, and also to one end of a dough snake.
  3. Connect the other end of the dough snake to GND.
  4. Connect the speaker between digital pin 9 and GND.
  5. Open the Squishy Sound code from the guide in the Arduino software and upload it.
  6. Squish, stretch and poke the dough and listen to the pitch change.
Arduino wiring for Squishy Sound: 5V through a 470 ohm resistor to pin A0 and a dough snake to ground, with a speaker on pin 9
Wiring for Squishy Sound.

What happens

The pitch follows the dough. Stretching it longer and thinner raises its resistance and the pitch, and squishing it shorter and thicker lowers them.

Not working?

No sound? Check that the dough touches both wires firmly and that the speaker is on pin 9. Open the Serial Monitor to see the numbers the Arduino reads from the dough. If they never change, check the resistor and the A0 wire.

Key words

Arduino
A small programmable circuit board that can read sensors and control lights, sounds and motors.
Sensor
A part that measures something in the world and turns it into an electrical signal.
Voltage divider
Two resistances in series that split a voltage between them.
Analog input
A pin that reads a range of voltages as numbers, from 0 to 1023 on an Arduino Uno.
Variable
A named place in a program that stores a value, like the reading from the dough.

For teachers

The guide's learning objectives: explain how resistance, voltage and current are related; explore how physical shape affects resistance; design and build a circuit to reach a goal; and modify and run code on a microprocessor. It includes background on Ohm's law, voltage dividers and breadboards.

Squishy Circuits began as research at the University of St. Thomas. You can read the original research paper on Squishy Circuits as tangible interfaces. Find more lessons on our education page.

Coding questions

Can you use play dough with an Arduino?

Yes. Conductive dough works as a variable resistor. Paired with a fixed resistor in a voltage divider, it gives the Arduino a voltage that changes as you squish the dough.

What resistor should I use with conductive dough?

Our guide uses a 470 ohm resistor for each piece of dough. You can experiment with other values and watch how the readings change.

Why does stretching the dough raise the pitch?

A longer, thinner piece of dough has more resistance. That raises the voltage the Arduino reads, and the code turns a higher reading into a higher pitch.

Do I need to know how to code?

No. The guide includes the complete code for both projects. Start by uploading it as is, then try changing numbers to see what happens.

Will the Squishy Circuits buzzer work for Squishy Sound?

No. The buzzers in the kits make their own built-in sound, so the Arduino cannot change their pitch. Squishy Sound needs a small speaker.