Código de Pesquisa

Contador Touch RoboJax V3 Usando Display LED de 4 Dígitos TM1637

Contador Touch RoboJax V3 Usando Display LED de 4 Dígitos TM1637

```html

Schematic of TTP223 module

RoboJax Contador Táctil V3 Usando Display LED de 4 Dígitos TM1637

Este projeto demonstra como construir um contador de toques usando um sensor táctil TTP223 e um display LED de 4 dígitos TM1637. Cada toque incrementa o contador, exibido no LED. Um botão de reset permite redefinir a contagem para zero. Este projeto simples fornece uma base para várias aplicações e é uma ótima introdução à interface de sensores e displays com o Arduino.

Aqui estão algumas ideias de projetos usando este contador de toque:

  • Contador simples para eventos ou inventário.
  • Contador de voltas para corridas ou jogos.
  • Contador de visitantes para exposições ou salas.
  • Contador de repetições para rotinas de exercícios.

Hardware/Componentes

  • Arduino Uno (ou placa compatível)
  • Módulo de Sensor de Toque TTP223 ou TTP223B
  • Módulo de Display LED de 4 Dígitos TM1637
  • Botão de pressão (para reinicialização)
  • Fios jumper
  • Placa de protótipo (opcional)

Guia de Fiação

Para o sensor de toque TTP223:

  • VCC para Arduino 5V
  • GND para GND do Arduino
  • SIG/IO/OUT para o pino 2 do Arduino (pode ser alterado no código)

Para o display TM1637:

  • VCC para Arduino 5V
  • GND para GND do Arduino
  • CLK para o pino 10 do Arduino
  • DIO para o pino 11 do Arduino

Para o botão de reset:

  • Um terminal ao GND do Arduino
  • Outro terminal para o pino 12 do Arduino (pode ser alterado no código)

Explicação do Código

Este esboço utiliza oTM1637biblioteca. Instale-a através do Gerenciador de Bibliotecas do IDE Arduino.

Elementos chave configuráveis no código:


#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)

Ajuste essas definições de pinos se estiver usando pinos diferentes. OtouchDelayvariável (no vídeo às 04:15) impede contagens múltiplas de um único toque. Um divisor de tensão não é necessário para o sensor de toque ou botão de reset, pois o resistor pull-up interno do Arduino é usado para o botão de reset, e o módulo do sensor de toque gerencia sua própria regulação de tensão.

As linhas a seguir inicializam o monitor serial e definem o estado de exibição inicial:


Serial.begin(9600);
display.setBrightness(0x0f); // Set brightness (0x00 to 0x0f) (in video at 05:24)
display.showNumberDec(0); // Initial display value

O loop principal lê os estados do sensor de toque e do botão de reset. Se o sensor de toque for ativado, a contagem incrementa e é exibida. Se o botão de reset for pressionado, a contagem volta a zero.

Projeto Vivo/Demonstração

A demonstração mostra o contador incrementando a cada toque e zerando quando o botão é pressionado. O monitor serial também exibe a contagem atual. O "8888" inicial no display confirma que o display está funcionando corretamente.

Capítulos

  • [00:00] Introdução e Visão Geral do Projeto.
  • [00:34] Componentes e Explicação.
  • [02:41] Explicação do Código.
  • [07:54] Instruções de Fiação.
  • [09:27] Demonstração do Projeto.

```

Imagens

Robojax Touch Counter V3 usando display LED de 4 dígitos TM1637
Robojax Touch Counter V3 usando display LED de 4 dígitos TM1637
TTP223B touch module
TTP223B touch module
TTP223 Touch module - Top view
TTP223 Touch module - Top view
TTP223 Touch module - Top view
TTP223 Touch module - Top view
Schematic of TTP223 module
Schematic of TTP223 module
167-RoboJax Touch Counter V3 using TM1637 4-digit LED display
Idioma: C++
/*
 * 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
}

Arquivos📁

Bibliotecas do Arduino (zip)

Arquivo Fritzing

Manual do Usuário