RoboJax Touch Counter V3 utilizza il display LED a 4 cifre TM1637
```html

RoboJax Touch Counter V3 utilizza il display LED a 4 cifre TM1637
Questo progetto dimostra come costruire un contatore tattile utilizzando un sensore tattile TTP223 e un display LED a 4 cifre TM1637. Ogni tocco incrementa il contatore, visualizzato sul LED. Un pulsante di reset consente di riportare il conteggio a zero. Questo semplice progetto fornisce una base per varie applicazioni ed è una grande introduzione all'interfacciamento di sensori e display con Arduino.
Ecco alcune idee di progetti utilizzando questo contatore di tocchi:
- Contatore semplice per eventi o inventario.
- Contatore di giri per gare o giochi.
- Contatore di visitatori per mostre o stanze.
- Contatore di ripetizioni per routine di esercizio.
Hardware/Componenti
- Arduino Uno (o scheda compatibile)
- Modulo sensore tattile TTP223 o TTP223B
- Modulo display LED a 4 cifre TM1637
- Pulsante (per reset)
- Cavi jumper
- Breadboard (opzionale)
Guida al cablaggio
Per il sensore tattile TTP223:
- VCC a Arduino 5V
- GND a GND di Arduino
- SIG/IO/OUT al pin 2 di Arduino (può essere cambiato nel codice)
Per il display TM1637:
- VCC a Arduino 5V
- GND a GND di Arduino
- CLK su pin 10 di Arduino
- DIO a Arduino pin 11
Per il pulsante di reset:
- Un legame a GND di Arduino
- Altro piede al pin 12 di Arduino (può essere cambiato nel codice)
Spiegazione del codice
Questo schizzo utilizza ilTM1637libreria. Installala tramite il Gestore delle Librerie dell'Arduino IDE.
Elementi chiave configurabili nel codice:
#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)
Regola queste definizioni di pin se stai utilizzando pin diversi. IltouchDelayla variabile (nel video alle 04:15) previene conteggi multipli da un solo tocco. Un partitore di tensione non è necessario per il sensore tattile o il pulsante di reset perché il resistore di pull-up interno dell'Arduino viene utilizzato per il pulsante di reset, e il modulo del sensore tattile gestisce la propria regolazione della tensione.
Le seguenti righe inizializzano il monitor seriale e impostano lo stato di visualizzazione iniziale:
Serial.begin(9600);
display.setBrightness(0x0f); // Set brightness (0x00 to 0x0f) (in video at 05:24)
display.showNumberDec(0); // Initial display value
Il ciclo principale legge gli stati del sensore di tocco e del pulsante di reset. Se il sensore di tocco è attivato, il conteggio aumenta e viene visualizzato. Se il pulsante di reset viene premuto, il conteggio si azzera.
Progetto dal vivo/Demonstrazione
La dimostrazione mostra il contatore che aumenta ad ogni tocco e si azzera quando il pulsante viene premuto. Il monitor seriale mostra anche il conteggio attuale. L'iniziale "8888" sul display conferma che il display sta funzionando correttamente.
Capitoli
- [00:00] Introduzione e panoramica del progetto.
- [00:34] Componenti e Spiegazione.
- [02:41] Spiegazione del codice.
- [07:54] Istruzioni di cablaggio.
- [09:27] Dimostrazione del progetto.
```
/*
* 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
}
Cose di cui potresti avere bisogno
-
Amazon
-
Amazon
-
eBay
-
AliExpressTM1637 4-digit 7-segment display on AliExpresss.click.aliexpress.com
File📁
Librerie Arduino (zip)
-
Libreria TM1637 per Arduino
TM1637_library.zip1.36 MB
File Fritzing
-
Modulo a sette segmenti TM1637
TM1637.fzpz0.01 MB -
Display a sette segmenti a 4 cifre TM1637
TM1637-1.fzpz0.01 MB
Manuale dell'utente
-
Manuale del Display TM1637
robojax-TM1637_display_manual.pdf0.31 MB