ESP32-S3 Lab · Day 14 of 30

Make your fingertip
the switch

Today your own fingertip becomes the switch. One bare jumper on GPIO 14 is the touch pad, and the pin keeps charging it and measuring how much charge it holds. Your finger adds a little capacitance of its own, the reading jumps, and the sketch flips the LED — the same way a phone screen and an elevator button know a finger is there.

About 25 minutesArduino firstNo electronics assumedYour finger is the button
Agent assist code TSK-DAY14-TOUCH

Hand this to an agent so it can pull the lesson packet and coach you step by step.

01 First, know the pieces

What you need

Six things, and one of them doubles as the sensor. Tap Define on any part you haven't met — the answer opens as a field note you can read and dismiss without losing your place.

Official manual photo of the ESP32-S3 development board.
Manual photo

ESP32-S3 board

The brain that runs your uploaded sketch.

Official manual image of the ESP32-S3 GPIO extension board.
Manual photo

GPIO extension board

Spreads the pins into rows you can reach and label.

Official manual photo of a red LED with its longer positive leg and shorter negative leg labelled.
Manual photo

LED

The lamp you'll flip with a tap — it only works one way round.

Official manual photo of a resistor with coloured value bands.
Manual photo

220 Ω resistor

Sits in series with the LED to keep the current gentle.

Official manual image of a jumper wire.
Manual photo

3 × jumper wires

Two carry the LED circuit; the third sits alone on GPIO 14 with its free end bare — that tip is the touch pad.

Official manual screenshot of the Arduino IDE interface.
Manual screenshot

Arduino IDE

Uploads the sketch to the board.

02 Make the physical circuit

Chart the circuit

The official Freenove diagram is your chart — schematic on top, the same circuit built on a breadboard below. Click it to enlarge. The touch pad is the simplest sensor of the whole course — a single jumper with a bare end.

Official Freenove circuit — C Tutorial, Chapter 9 (Touch Sensor), page 105.
Bare jumper end GPIO 14 (T14) The exposed metal tip is the touch pad your fingertip charges.
LED long leg (+) GPIO 21 via 220 Ω This pin holds the lamp on or off between touches.
LED short leg (−) GND Completes the LED's path back to zero volts.

Keep the touch wire to itself. The free end of the GPIO 14 jumper is for your skin only — keep it clear of 3.3V, 5V, and every other pin. Unplug USB before you move any wire.

03 One action at a time

Build it

This is the main path — you can finish the day without opening a single field note. Tap each step as you go to keep your place.

0 / 8 done
  1. Seat the ESP32-S3 on the GPIO extension board and keep USB unplugged while you wire.

  2. Place the LED so its long leg (+) is on the GPIO 21 side and its short leg (−) heads toward ground.

  3. Put the 220 Ω resistor in series between GPIO 21 and the LED's long leg.

  4. Push one end of a jumper into GPIO 14 and leave its other end free in the air — that bare metal tip is your touch pad.

  5. Compare every wire to the chart, then plug in USB.

  6. Open Sketch_09.1_TouchRead.ino first, upload it, and open Serial Monitor at 115200 — note the reading when the wire is alone and when you pinch its bare tip.

  7. Open Sketch_09.2_TouchLamp.ino and upload it.

  8. Tap the bare tip — the LED flips on. Tap again — it flips off.

The wire feels you.

One tap on, one tap off — the board is reading your fingertip directly. Head to Test & debug to confirm the toggle.

04 Read just enough code

Read the code

Two sketches today. Sketch_09.1_TouchRead.ino is the calibration tool — it prints the raw touch reading once a second so you can see your own numbers. The lamp itself is 9.2, shown below — two thresholds, a remembered flag, and a tiny helper that flips the LED.

Sketch_09.2_TouchLamp.ino
#define PIN_LED     21
#define PRESS_VAL   200000	  //Set a threshold to judge touch
#define RELEASE_VAL 60000	    //Set a threshold to judge release

bool isProcessed = false;
void setup() {
  Serial.begin(115200);
  pinMode(PIN_LED, OUTPUT);
}
void loop() {
  if (touchRead(T14) > PRESS_VAL) {
    if (!isProcessed) {
      isProcessed = true;
      Serial.println("Touch detected! ");
      reverseGPIO(PIN_LED);
    }
  }
  if (touchRead(T14) < RELEASE_VAL) {
    if (isProcessed) {
      isProcessed = false;
      Serial.println("Released! ");
    }
  }
}

void reverseGPIO(int pin) {
  digitalWrite(pin, !digitalRead(pin));
}
touchRead(T14)Measures the charge on touch pin T14, which is GPIO 14 — your fingertip drives this number far higher.
touchRead(T14) > PRESS_VALOn this board a reading above 200000 counts as a touch; a reading below 60000 counts as a release.
bool isProcessedRemembers that the current touch has already been handled, so one tap flips the lamp exactly once.
digitalWrite(pin, !digitalRead(pin))Reads the LED pin's current state and writes the opposite — the flip itself.

05 Understand, don't memorise

How a bare wire feels your finger

Before the sketch, the one idea that makes a bare wire work as a sensor. The pin is always busy — charging the wire and measuring how much charge it holds, thousands of times a second. Your finger changes that measurement, and touchRead hands you the result as a plain number you can act on.

Charge

Fill a tiny capacitor

The pin pushes a small charge onto the bare wire again and again. The wire holds a little of it — that ability to hold charge is its capacitance.

Measure

How much it holds

Each cycle the pin measures how the charge builds up on the wire. With nothing near, that settles to a steady resting number.

Your finger

You add capacitance

Your body stores charge too. A fingertip near the wire adds its own capacitance, so the wire holds more and the measurement moves.

Report

touchRead

touchRead(T14) returns that measurement as a number. On this board it climbs far past its resting value the instant you touch.

The model your finger's capacitance lifts the reading past 200000 (press); releasing lets it fall below 60000 (release)

Why no button and no moving part

Nothing presses or closes here. The pin senses the change in its own electric field as your finger comes near, so a bare wire — even one behind a panel or a sheet of glass — does the whole job. This is the same sensing behind phone screens and elevator buttons.

Why the threshold sits between resting and touched

The resting reading and the touched reading are two separated levels, and a threshold is any line you draw between them — above it means touched, below it means clear. The sketch draws two lines, a high one (PRESS_VAL) to call a press and a lower one (RELEASE_VAL) to call release, so a reading wavering near a single line can't flip the lamp back and forth.

On this board a touch pushes the number up

Idle, the pin reads in the tens of thousands; a firm touch climbs past 200000. Older ESP32 chips reported touch as a drop toward zero, and some reference text still describes that — on your S3, trust the thresholds in the sketch and the numbers you read yourself.

06 Know it worked

Test & debug

The Serial Monitor is your calibration tool today — the proof is the LED answering your fingertip.

What you should see
LED
  • Tap the bare end of the wire — the LED flips on and stays on.
  • Tap it again — the LED flips off.
  • Serial Monitor at 115200 echoes each touch with "Touch detected! " and each let-go with "Released! ".

This lamp latches — the LED holds its state between taps, with your fingertip doing the whole job of a button.

If it doesn't
  • LED never flips? The thresholds may sit wrong for your setup — upload Sketch_09.1_TouchRead and read your own touched and untouched numbers.
  • LED flickers wildly? Hold the wire by its insulation and touch only the bare metal end, deliberately.
  • Nothing on the Serial Monitor? Set the monitor to 115200 baud, then re-check the board and port selections.
  • Upload fails? Swap in a data-capable USB cable.

07 Make the idea yours

Try this: tune it to your own hand

Same working circuit, two numbers to make your own. The stock thresholds fit most hands; yours deserve a proper fit, drawn from readings you take yourself. It sits inside today's 25 minutes.

Read your numbers

Upload Sketch_09.1_TouchRead.ino — it prints the raw touchRead value once a second. Watch the Serial Monitor and write down two readings- the wire alone, and your fingertip pinching the bare tip. They sit far apart. Set PRESS_VAL a little below your touched number and RELEASE_VAL a little above your idle number — you're drawing your own line between the two — then re-upload the lamp.

Demand a firm grip

Raise PRESS_VAL step by step until a light brush does nothing and only a firm, deliberate grip flips the lamp. You've just designed how the switch should feel.

08 Learn it with a hand on the tiller

Coach me through it

Every lesson ships with a code and a machine-readable packet, so an agent can guide you with full context.

Lesson code

TSK-DAY14-TOUCH

How the agent should behave: guide one physical connection at a time and wait for confirmation, and make sure the learner leaves understanding the mechanism — the pin charges the bare wire and measures its capacitance, a fingertip adds more, and a threshold they pick from their own readings turns that into a touch. Always check wiring, board, port, and USB before changing code.

Keep your place

Finished Day 14?

Mark it complete — it shows on your course map, and your place is saved on this device.

Field note

Shortcut

Prompt copied