Built-in project · no microcontroller

Squeeze and bend

A force-sensing resistor lights a lamp harder the harder it is pressed, and a flex sensor climbs from 25 k on a multimeter as it bends. There is no microcontroller in it: the simulator solves the 5 parts as a circuit, so it runs the moment you press Run, and nothing needs compiling.

Teaching? Assign it to your class in one click.

Beginner About 10 minutes to build and run. Runs in your browser. Free, and no account needed.

The parts retail for about $16.15. On Mokxi they're free.

The circuit runs here once the page has loaded.

What you'll learn

  • How a force-sensing resistor changes with pressure
  • How a flex sensor's resistance grows as it bends
  • Measuring resistance with a multimeter
  • Using a variable resistor to set LED brightness
  • Difficulty: Beginner
  • Time: About 10 minutes
  • Parts: 6

How it works

This circuit has no code. On one side, 5 V runs through a 220 ohm resistor, a yellow lamp and a force-sensing resistor to ground. The sensor is open until about 20 grams, so the lamp is off. Press harder and its resistance falls from about 36k to under 1k at 2 kg, so the lamp goes from dim to bright.

On the other side, a multimeter on its ohms setting is across a flex sensor. It reads 25k when flat and climbs as you bend the sensor.

Parts list

6 parts, plus the jumper wires and a bench instrument. The parts retail for about $16.15; on Mokxi they're free, and so are the instruments.

Wiring table

Every connection, pin by pin, read from the circuit itself. Each row joins the pin on the left to the pin on the right, by a jumper wire or a breadboard strip.

Part and pinConnects to
Resistor, 220 Ω pin 15 V
Force-sensing resistor pin 1Ground
LED, yellow pin AResistor, 220 Ω pin 2
Force-sensing resistor pin 2LED, yellow pin C
Multimeter pin VFlex sensor pin 1
Multimeter pin COMFlex sensor pin 2

The notes that come with it

There is no microcontroller in this one, so nothing is compiled: the simulator solves the circuit itself. The file in the editor is the notes that come with it.

sketch.ino
// Squeeze and bend: an FSR lighting a lamp, a flex sensor on a meter.
//
//   5 V -> 220 ohm -> lamp -> FSR -> ground
//   meter on ohms, across the flex sensor
//
// The FSR is open until about 20 g, then falls from about 36 k to under 1 k
// at 2 kg, so the lamp goes from off, to dim, to bright. The flex sensor is
// 25 k flat and climbs as it bends.

Troubleshooting

The usual mistakes with this circuit, and the fix for each.

  • The lamp stays off when you press lightly This project
    The force sensor stays open until about 20 grams. Press harder to start the lamp.
  • The multimeter shows nothing sensible This project
    Make sure the meter is set to ohms and across the flex sensor's two pins.
  • The LED is dim, burns out, or the pin reads wrong because the resistor value is off. Resistor
    Read the color bands again. A 220 ohm to 330 ohm resistor suits a typical LED on 5 V. 10k is a common pull-up or pull-down value. Check with a multimeter if unsure.
  • A pull-up or pull-down resistor is missing, so the input floats and reads random values. Resistor
    Tie the input to 5 V or ground through about 10k. Or use INPUT_PULLUP and wire the switch to ground.
  • The LED does not light, or it lights once and then dies. LED
    LEDs have polarity. The longer leg (anode) goes toward the positive side. Always add a series resistor, about 220 ohms to 1 k ohm on a 5 V pin.
  • A blue or white LED stays dark on 3.3 V. LED
    Blue and white LEDs drop about 3 V, so 3.3 V leaves almost nothing for the resistor. Use a 5 V supply, or a smaller resistor and a red or green LED.
  • The analog reading is always near 0 or noisy. Force-sensing resistor
    An FSR changes resistance, so build a divider. Put about 10k from the analog pin to ground and the FSR to 5 V. Without the fixed resistor the pin floats.
  • The force reading is not accurate in grams. Force-sensing resistor
    FSRs are not precise and vary part to part. Use them to tell light from hard presses, and calibrate against known weights if you need numbers.

Change it and keep it

Open it in the editor, change the circuit or the code, and keep your version in a free account.