Source: https://mokxi.com/parts/touchfoil
Updated: 2026-11-16

Part

# Touch foil

A piece of foil for the CapacitiveSensor library. A finger adds about 100 pF, and the count climbs.

See every part

- 1 pin
- 2 settings
- In 1 project

Drawn live by the editor's own code, at the size you see it.

At a glance

## The Touch foil in brief

What it is, and every setting the properties panel gives it.

The touch foil is a piece of aluminum foil on a wire: the touch sensor of the CapacitiveSensor library and the Starter Kit’s touchy-feely lamp. There is no chip on it. The foil is one plate of a capacitor and the room is the other, a few picofarads, and a finger adds the body’s capacitance, about a hundred more. The one pin is FOIL: wire it to the receive pin, with a resistor of about 1 megohm to the send pin. The pad property is the foil and its lead alone in picofarads, 10 by default, and finger is what a touch adds, 100 by default. The foil is a capacitor to ground solved in the circuit’s matrix, so the count is the real RC time through the resistor you chose. Hold the pointer on the foil to touch it. A hand coming near is not modeled.

Family

Inputs

Pins

1

pad

10

finger

100

Pins

## The one pin

Named as the editor names them, so a wire lands where you expect it.

Pin

What it does

FOIL

The foil. Wire it to the receive pin, with a resistor of about 1 megohm to the send pin.

How to use it

## How to build a touch sensor from foil with an Arduino

A 1 megohm resistor goes from pin 4, the send pin, to pin 2, the receive pin, and the foil is on pin 2. That is the Arduino Starter Kit’s touchy-feely lamp, and the lamp is the Uno’s own LED on pin 13. The foil’s FOIL pin goes to the same node as pin 2 and the resistor’s other end.

Paul Badger’s CapacitiveSensor library flips the send pin and counts how long the receive pin takes to follow through the resistor. A touch makes the count several times larger, because the finger adds about 100 pF to the pad’s 10. A larger resistor gives a larger count. The sketch lights the LED when the count passes 100. Hold the pointer on the foil to touch it.

Part pin

Goes to

FOIL

Pin 2, and one end of the 1 M resistor

1 M resistor

Pin 4, to pin 2

LED

The Uno’s own LED on pin 13

Hold the button

This is the simulator itself, running here. Click anything to open it in the editor.

Open this project in the editor Read the full tutorial

Light the lamp on a touch

Common errors

## Common Touch foil errors and fixes

What goes wrong

The fix

The count never changes.

The resistor is between the send pin and the receive pin, and the foil is on the receive pin. Check pins 4 and 2.

The lamp is always on or always off.

Print the count and set the threshold between the untouched and touched values. A larger resistor gives larger counts.

It does not sense through paper.

A real count rises as a hand approaches, which is how it senses through paper. The model does not do that: it reacts to a touch only.

Questions

## Questions and answers

### How does the touch foil work?

The foil is one plate of a capacitor and the room the other, a few picofarads. A finger adds about a hundred more, so the RC time through the resistor is several times longer.

### What resistor does the CapacitiveSensor library need?

About 1 megohm, from the send pin to the receive pin, with the foil on the receive pin.

### Which pins does the Starter Kit lamp use?

Send on pin 4, receive and foil on pin 2, and the Uno’s LED on pin 13.

How it is modeled

## What is true about the Touch foil, here

In its help article’s own words: what the simulation gets right, and where it stops.

### Modeled

The foil is a capacitor to ground solved in the circuit's matrix, so the count
the library reads is the real RC time through the resistor you chose: a larger
resistor gives a larger count, and a touch multiplies it by the ratio of the
capacitances.

### Not modeled

A hand coming near before it touches (the real count rises as the hand
approaches, which is how it senses through paper), mains hum picked up by the
body, and the board's ground not being earth.

From Touch foil, in full.

Projects

## See the Touch foil in a project

One built-in project uses it. It opens in the editor, already wired.

Boards

## The boards it is shown on

This board has a built-in project with the Touch foil in it.

- Arduino Uno R3

Libraries

## Arduino libraries for the Touch foil

Built in, so the sketch compiles with nothing to install. Each page has the calls, the wiring and an example to run.

- CapacitiveSensor

Keep going

## Keep going

- Arduino MPR121: 12-Key Capacitive Touch Piano
- Arduino Button Debounce: See the Bounce, Then Fix It
- Touch sensor, TTP223
- Capacitive touch, MPR121
- Pushbutton

More parts

## The rest of the bench

Every one of these is drawn and simulated the same way.

Full-size breadboard

A real 0.1 inch grid with the rails and the center channel, 63 columns wide.

Jumper wires

Drag from any pin or hole to any other. Corners snap, and you can drag them.

Power

A supply rail at the voltage you choose.

Ground

The other end of every circuit.

LED

Lights when current flows. Five colors, and the brightness is what your eye would see.

Filament lamp

A tungsten bulb in a holder: an inrush when it is switched on cold, tens of milliseconds to warm up, and dim on half its voltage.

Resistor

Any value you like, with the color bands drawn to match.

ESP32-C3-DevKitM-1

A RISC-V board that runs your firmware at 160 MHz on the real memory map.

Pushbutton

A 12 mm tactile switch. Hold it while the simulation runs.

Raspberry Pi Pico

The RP2040 board on our own Cortex-M0+ core. Pick a program and press Run.

Raspberry Pi Pico W

Raspberry Pi Pico W (RP2040). The same board and the same pinout as a Pico, with the CYW43439 on it. The WiFi is simulated (no radio; real internet through the Cloud panel’s switch), and the on-board LED, which hangs off that chip rather than off GP25, is driven through the same path. Everything else is the Pico.

Raspberry Pi 4 Model B

Raspberry Pi 4 Model B: the 40-pin header, driven by main.py with RPi.GPIO or gpiozero.

See every part

## Wire up the Touch foil

Open the editor and push it into the breadboard. It is free, and it runs on your own machine.

Start building free Open the editor
