TinySkiff 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 acts as a touch pad, and the sketch watches the tiny charge your skin adds to it — one tap flips the LED on, the next tap flips it off.

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

A pin that feels your fingertip

Your skin holds a small electric charge, and pressing it against the bare wire lets the pin feel that extra capacitance as a bigger number. The rest is bookkeeping the sketch does for you.

Sense

touchRead

The pin measures how much charge the bare wire is soaking up.

Compare

Two thresholds

Above 200000 counts as a touch and below 60000 counts as a release.

Remember

isProcessed

A flag makes sure each touch flips the lamp exactly once.

Act

Flip

reverseGPIO reads the LED pin and writes the opposite state.

The model touch raises the reading — above 200000 is a press and below 60000 is a release

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 behaviour — on your S3, trust the thresholds in the sketch.

The same trick as the table lamp

The isProcessed flag plays the role debounce played on Day 5 — it holds the memory of one press so a long touch counts as a single tap.

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. It sits inside today's 25 minutes.

Read your numbers

Upload Sketch_09.1_TouchRead.ino again and write down two values — the reading with the wire alone and the reading with your fingertip pinching the bare tip. Set PRESS_VAL a little under your touched value and RELEASE_VAL a little over your idle value, 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.

Logbook

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, wait for you to confirm, explain terms on request, and always check wiring, board, port, and USB before changing code.

Field note

Shortcut

Prompt copied