TTP223 | ||
Avant le Setup | Importation de la bibliothèque | |
Création de l’objet | const int brocheCapteur = D2; | |
Dans le Setup | Démarrage de l’objet | pinMode(brocheBouton, INPUT); |
Dans le Loop | Utilisation | digitalRead(brocheCapteur); |
1 ///////////////////////
2 // Capteur Capacitif //
3 // TTP223 //
4 ///////////////////////
5
6 /*
7 Ce programme est un exemple de base du capteur capacitif TTP223.
8 Il écrit "vous avez touché le capetur !" sur le moniteur série lorsque le capteur est activé.
9
10 Lolin (Wemos) D1 mini
11
12 _________________
13 / D1 mini \
14 |[ ]RST TX[ ]| Capteur capacitif TTP223
15 |[ ]A0 -GPIO RX[ ]| +-------------+
16 |[ ]D0-16 5-D1[ ]| .--|[X]VCC /‾‾‾‾\|
17 |[ ]D5-14 4-D2[X]|-----------|--|[X]I/O| |
18 |[ ]D6-12 0-D3[ ]| .-----|--|[X]GND \____/|
19 |[ ]D7-13 2-D4[ ]| / | |_____________|
20 |[ ]D8-15 GND[X]|---' /
21 |[ ]3V3 . 5V[X]|----------'
22 | +---+ |
23 |_______|USB|_______|
24
25
26 Matériel :
27 - Des fils dupont.
28 - Un LOLIN (Wemos) D1 mini
29 - Capteur capacitif TTP223
30
31
32 Schéma de l'Arduino en ASCII-ART CC-By http://busyducks.com/ascii-art-arduinos
33 Sous licence CC-By-Sa (http://creativecommons.org/licenses/by-nc-sa/3.0/)
34 ___
35 / ___ \
36 |_| |
37 /_/
38 _ ___ _
39 |_| |___|_| |_
40 ___|_ _|
41 |___| |_|
42 Les petits Débrouillards - janvier 2023- CC-By-Sa http://creativecommons.org/licenses/by-nc-sa/3.0/
43 Inspiré de :
44 TTP223B-Capacitive-Touch-Switch-Module - 08 Nov 2020
45 by Amir Mohammad Shojaee @ Electropeak
46 https://electropeak.com/learn/interfacing-ttp223-capacitive-switch-butto-touch-sensor-with-arduino/
47
48 */
49 const int brocheCapteur = D2;
50
51 void setup() {
52 Serial.begin(9600);
53 // initialisation de la broche en entrée (INPUT)
54 pinMode(brocheCapteur, INPUT);
55 }
56
57 void loop() {
58 if(digitalRead(brocheCapteur) == HIGH){
59 Serial.println("Vous avez touché le capteur !");
60 while(digitalRead(brocheCapteur) == HIGH){}
61 }
62 }
Vous avez entré un nom de page invalide, avec un ou plusieurs caractères suivants :
< > @ ~ : * € £ ` + = / \ | [ ] { } ; ? #