🛠 Toucher capacitif : touchRead sans composant

Arduino UNO R4 WiFi · debutant · Schéma : IMG-uno-r4-wifi-debutant-3-ur4wifi-touch-capacitif.svg — UNO R4 WiFi avec un fil nu relié à une broche tactile, doigt pointant sur le fil, moniteur série affichant deux niveaux (repos ~0, touché > 100), matrice LED affichant un smiley.

Objectives

Use the RA4M1's capacitive touch peripheral (CTSU): 14 pins on the board can serve as capacitive touch sensors, read by a simple touchRead call from the official CapacitiveTouch library. You will calibrate a threshold by observing actual values, then trigger an LED matrix display — a button without a button, without resistors or wires other than a piece of conductor.

Hardware

Complete Code

#include <CapacitiveTouch.h>

const uint8_t PAD = A1;      // une broche compatible toucher
const int SEUIL = 100;       // à calibrer avec le Moniteur série !

void setup {
  Serial.begin(115200);
}

void loop {
  int v = touchRead(PAD);    // ~0 au repos, monte franchement au toucher
  Serial.println(v);
  if (v > SEUIL) {
    MatrixSmiley;          // votre fonction d'affichage (voir tuto matrice)
  }
  delay(20);
}

Expected Verification

At rest, touchRead displays a low and stable value; as soon as a finger touches the bare wire (or the board near the relevant pin), the value rises significantly above the threshold. Fine-tune the threshold to the midpoint between your two measurements: this is THE correct calibration method, identical to that of an analog sensor.

Common Errors

Other tutorials for this board

Code examples for this board

← Back to the board 🛠 All tutorials