كود البحث

عداد لمسة RoboJax V3 باستخدام شاشة LED رباعية الأرقام TM1637

عداد لمسة RoboJax V3 باستخدام شاشة LED رباعية الأرقام TM1637

```html

Schematic of TTP223 module

عداد اللمس RoboJax Touch V3 باستخدام شاشة LED رباعية الرقم TM1637

يظهر هذا المشروع كيفية بناء عداد لمسة باستخدام حساس اللمس TTP223 وشاشة LED ذات 4 أرقام TM1637. كل لمسة تزيد من العداد، المعروض على LED. يسمح زر إعادة الضبط بإعادة تعيين العداد إلى الصفر. يوفر هذا المشروع البسيط أساسًا لمجموعة متنوعة من التطبيقات ويمثل مقدمة رائعة لتوصيل الحساسات والشاشات مع أردوينو.

إليك بعض أفكار المشاريع باستخدام جهاز العد باللمس:

  • عداد بسيط لحساب الأحداث أو المخزون.
  • عداد اللفات للمسابقات أو الألعاب.
  • عداد الزوار للمعارض أو الغرف.
  • عداد التكرارات لتمارين الروتين.

العتاد/المكونات

  • اردوينو أونو (أو لوحة متوافقة)
  • وحدة استشعار اللمس TTP223 أو TTP223B
  • وحدة عرض LED مكونة من 4 أرقام TM1637
  • زر دفع (لإعادة التعيين)
  • أسلاك التوصيل
  • لوحة تجريبية (اختياري)

دليل الأسلاك

بالنسبة لمستشعر اللمس TTP223:

  • VCC إلى أردوينو 5 فولت
  • GND إلى GND لآردوينو
  • SIG/IO/OUT إلى دبابيس Arduino 2 (يمكن تغييره في الكود)

لعرض TM1637:

  • VCC إلى أردوينو 5 فولت
  • GND إلى GND في الأردوينو
  • CLK إلى السلك 10 في أردوينو
  • DIO إلى الدبوس 11 في أردوينو

زر إعادة الضبط:

  • ساق واحدة إلى GND في Arduino
  • الساق الأخرى إلى دبابيس أردوينو 12 (يمكن تغييرها في الكود)

شرح الكود

هذا الرسم التخطيطي يستخدم الـTM1637المكتبة. قم بتثبيتها عبر مدير المكتبات في بيئة تطوير أريدوينو.

عناصر قابلة للتكوين الرئيسية في الكود:


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

قم بتعديل هذه التعريفات للدبابيس إذا كنت تستخدم دبابيس مختلفة.touchDelayتمنع المتغيرات (في الفيديو عند 04:15) العد المتعدد من لمسة واحدة. لا حاجة لمقسم جهد لجهاز الاستشعار اللمسي أو زر إعادة الضبط لأن مقاوم السحب الداخلي لاردوينو يُستخدم لزر إعادة الضبط، ويتعامل نموذج جهاز الاستشعار اللمسي مع تنظيم الجهد الخاص به.

السطور التالية تقوم بتهيئة الشاشة التسلسلية وتحدد حالة العرض الأولية:


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

تقرأ الحلقة الرئيسية حالة مستشعر اللمس وزر إعادة الضبط. إذا تم تنشيط مستشعر اللمس، تزداد العدّاد ويتم عرضها. إذا تم الضغط على زر إعادة الضبط، تعود العدّاد إلى الصفر.

عرض المشروع/التوضيح

توضح التجربة كيف يزداد العدد مع كل لمسة ويعاد تعيينه عند الضغط على الزر. كما يعرض المراقب التسلسلي العدد الحالي. الرقم الأول "8888" على الشاشة يؤكد أن الشاشة تعمل بشكل صحيح.

الفصول

  • [00:00] المقدمة ونظرة عامة على المشروع.
  • :34 المكونات والتفسير.
  • [02:41] شرح الكود.
  • [07:54] تعليمات التوصيل.
  • [09:27] عرض المشروع.

```

الصور

روبوجَکس عداد اللمس V3 باستخدام شاشة LED 4 أرقام TM1637
روبوجَکس عداد اللمس V3 باستخدام شاشة LED 4 أرقام 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
اللغة: 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
}

الأشياء التي قد تحتاجها

ملفات📁

مكتبات أردوينو (ملف مضغوط)

Fritzing File

دليل المستخدم