RoboJax Touch Compteur V3 Utilisant l'affichage LED à 4 chiffres TM1637
```html

RoboJax Compteur Tactile V3 Utilisant un Affichage LED 4 Chiffres TM1637
Ce projet démontre comment construire un compteur tactile utilisant un capteur tactile TTP223 et un affichage à LED 4 chiffres TM1637. Chaque toucher incrémente le compteur, affiché sur la LED. Un bouton de réinitialisation permet de remettre le compteur à zéro. Ce projet simple fournit une base pour diverses applications et constitue une excellente introduction à l'interface des capteurs et des affichages avec Arduino.
Voici quelques idées de projets utilisant ce compteur de touches :
- Compteur de score simple pour événements ou inventaire.
- Compteur de tours pour les courses ou les jeux.
- Compteur de visiteurs pour les expositions ou les salles.
- Compteur de répétitions pour les routines d'exercice.
Matériel/Composants
- Arduino Uno (ou carte compatible)
- Module de capteur tactile TTP223 ou TTP223B
- Module d'affichage LED 4 chiffres TM1637
- Bouton-poussoir (pour réinitialiser)
- Fils de connexion
- Planche à pain (optionnelle)
Guide de câblage
%%CÂBLAGE%%
Pour le capteur tactile TTP223 :
- VCC à Arduino 5V
- GND à GND Arduino
- SIG/IO/OUT vers la broche 2 de l'Arduino (peut être modifié dans le code)
Pour l'écran TM1637 :
- VCC sur Arduino 5V
- GND à GND Arduino
- CLK vers la broche 10 de l'Arduino
- DIO vers la broche 11 de l'Arduino
Pour le bouton de réinitialisation :
- Une jambe au GND d'Arduino
- Autre jambe sur la broche 12 de l'Arduino (peut être modifiée dans le code)
Explication du code
Ce croquis utilise leTM1637bibliothèque. Installez-la via le gestionnaire de bibliothèques de l'IDE Arduino.
Éléments configurables clés dans le code :
#define CLK 10 // clock pin
#define DIO 11 // data in-out pin
const int touchPin = 2; // touch sensor pin
const int resetPin = 12; // reset button pin
const int touchDelay = 500; // delay between touches (in ms) (in video at 04:15)
Ajustez ces définitions de broches si vous utilisez des broches différentes. LetouchDelayLa variable (dans la vidéo à 04:15) empêche les compteurs multiples d'un seul toucher. Un diviseur de tension n'est pas nécessaire pour le capteur tactile ou le bouton de réinitialisation car la résistance pull-up interne de l'Arduino est utilisée pour le bouton de réinitialisation, et le module du capteur tactile gère sa propre régulation de tension.
Les lignes suivantes initialisent le moniteur série et définissent l'état d'affichage initial :
Serial.begin(9600);
display.setBrightness(0x0f); // Set brightness (0x00 to 0x0f) (in video at 05:24)
display.showNumberDec(0); // Initial display value
La boucle principale lit les états du capteur tactile et du bouton de réinitialisation. Si le capteur tactile est activé, le compte s'incrémente et est affiché. Si le bouton de réinitialisation est enfoncé, le compte se remet à zéro.
Projet en direct/Démonstration
La démonstration montre le compteur s'incrémentant à chaque toucher et se réinitialisant lorsque le bouton est pressé. Le moniteur série affiche également le nombre actuel. Le "8888" initial sur l'écran confirme que l'affichage fonctionne correctement.
Chapitres
- [00:00] Introduction et aperçu du projet.
- [00:34] Composants et explication.
- [02:41] Explication du code.
- [07:54] Instructions de câblage.
- Démonstration de projet.
```
/*
* This is Arduino touch counter V3 using TTP223/TTP223B and TM1637 seven-segment LED Display.
* This program will function as a counter. Every time the touch module is touched,
* the counter increments by 1. The count number is displayed on the TM1637 display.
* We have a reset button to restart the counting from zero.
*
* Watch video instructions for this video: https://youtu.be/VzH9iEqrm0E
*
* Written by Ahmad Shamshiri on Sunday, October 28th at 10:33 in Ajax, Ontario, Canada.
* Get this code from Robojax.com
*
* This code is "AS IS" without warranty or liability. Free to be used as long as you keep this note intact.
* This code has been downloaded from Robojax.com.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
//***** beginning of TM1637 Display
#include <Arduino.h>
#include <TM1637Display.h>
// Module connection pins (Digital Pins)
#define CLK 10 // clock pin
#define DIO 11 // data in-out pin
// The amount of time (in milliseconds) between readings
#define TEST_DELAY 300
TM1637Display display(CLK, DIO);
uint8_t blank[] = { 0x0, 0x0, 0x0, 0x0 };// data to clear the screen
//***** end of TM1637 Display
const int touchPin = 2;// the input pin where touch sensor is connected
const int resetPin = 12;// the input pin for reset button
const int touchDelay = 500;//millisecond delay between each touch
int count=0;// variable holding the count number
void setup() {
// Robojax.com Touch counter 20181029
Serial.begin(9600);// initialize serial monitor with 9600 baud
Serial.println("Robojax Touch Counter V3");
pinMode(touchPin,INPUT);// define a pin for touch module
pinMode(resetPin,INPUT_PULLUP);// define a pin for reset button
// see video ( link in the video description) on using PULLUP
display.setBrightness(0x0f);// set brightness of display
uint8_t data8888[] = { 0xff, 0xff, 0xff, 0xff }; // all segments show
display.setSegments(data8888); // display 8888 on display for test
delay(3000);// give time to user to read the display at the beginning
display.setSegments(blank); // clear the screen from previous values
display.showNumberDec(0);// display zero at the belonging
// Robojax.com Touch counter 20181029
}
void loop() {
// Robojax.com Touch counter 20181029
int touchValue = digitalRead(touchPin);// read touchPin and store it in touchValue
// if touchValue is HIGH
if(touchValue == HIGH)
{
count++;// increment the count
display.setSegments(blank); // clear the screen from previous values
display.showNumberDec(count);// display the count
Serial.print("Touched ");//print the information
Serial.print(count);//print count
Serial.println(" times.");
delay(touchDelay);// touch delay time
}
// if reset switch is pushed
if(digitalRead(resetPin) == LOW)
{
count =0;// reset the counter;
Serial.println("Counter Resetted.");//print the information
display.setSegments(blank); // clear the screen from previous values
display.showNumberDec(count);// display the count
}
// Robojax.com Touch counter 20181029
}
Ce dont vous pourriez avoir besoin
-
Amazon
-
Amazon
-
eBay
-
AliExpressTM1637 4-digit 7-segment display on AliExpresss.click.aliexpress.com
Ressources et références
Fichiers📁
Bibliothèques Arduino (zip)
-
Bibliothèque Arduino TM1637
TM1637_library.zip1.36 MB
Fichier Fritzing
-
Module à sept segments TM1637
TM1637.fzpz0.01 MB -
Afficheur à sept segments à 4 chiffres TM1637
TM1637-1.fzpz0.01 MB
Manuel de l'Utilisateur
-
Manuel d'affichage TM1637
robojax-TM1637_display_manual.pdf0.31 MB