element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Arduino
  • Products
  • More
Arduino
Arduino Forum RFID - MFRC522
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Arduino to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • Replies 2 replies
  • Subscribers 392 subscribers
  • Views 308 views
  • Users 0 members are here
  • rfid_reader_module
Related

RFID - MFRC522

suro
suro over 8 years ago

Hello. I want to name what I have and then point to the problem: Arduino Uno, RFID module (MFRC522), LED, Coin Accepter CH 924.

Now the problem:

1. when there in the module is the first tag and Arduino gets 10 impulses from CH-924 - to send to LED 11 impulses.

2. when there in the module is the second tag and Arduino gets 10 impulses from CH-924 - to send to LED 12 impulses.

3. when there is no card in the module to send to LED as much impulses as it has received.

 

please help me with code

  • Sign in to reply
  • Cancel
  • fvan
    fvan over 8 years ago

    Do you already have anything available, like a schematic, and your code so far?

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • suro
    suro over 8 years ago in reply to fvan

    yes i have code

     

    #include <SPI.h>                                               

    #include <MFRC522.h>                                    

    MFRC522 rfid(10, 9); // пины SDA, RST                      

    unsigned long Key, KeyTemp;  // для храниения № ключа      

     

     

    const int buttonPin = 6; // номер входа, подключенный к кнопке

    const int ledPin = 7; // номер выхода светодиода

     

     

    boolean lastButten = LOW; // предыдущее состояние кнопки

    boolean currentButten = LOW; // текущее состояние кнопки

    int status = 0; // текущий статус

     

     

    void setup() {

      

      pinMode(buttonPin, INPUT);

      pinMode(ledPin, OUTPUT);

      Serial.begin(9600); // скорость порта

      SPI.begin();  //  инициализация SPI

      rfid.PCD_Init();}     // инициализация rfid модуля

      

    boolean debvance (boolean last) //убираем дребизг

    {

    boolean current = digitalRead (buttonPin); // считываем данные с кнопки

    if (last != current) // Если текущее состояни еотличететься от предыдущего

    {

    delay (5); // Ждем 5 милисек.

    current = digitalRead (buttonPin); // Присваеваем текущее состояние кнопки

    return current;

    }

    }

     

     

    void in(){

     

     

    currentButten = debvance (lastButten); // Передаем функции дребезга значение по умолчанию LOW

    if (lastButten == LOW && currentButten == HIGH) // Проверяем отпускали мы кнопку или нет

    {

    status = ++status; // инвертируем Статус

    }

    lastButten = currentButten; // Переприсваеваем прошлое состояние кнопки

     

     

    if (status == 10) //если статус 5

    {

    for (int i=0; i<10; i++){

    digitalWrite(ledPin,HIGH);

    delay(50);

    digitalWrite(ledPin,LOW);

    delay(50);

    }

    status = 0;

    }

    else // усди нажали не 5 раз выключаем светодиод

    {

    digitalWrite(ledPin,LOW);

    delay(20); // Ждем

    }

    }

     

     

    void tas(){

     

     

    currentButten = debvance (lastButten); // Передаем функции дребезга значение по умолчанию LOW

    if (lastButten == LOW && currentButten == HIGH) // Проверяем отпускали мы кнопку или нет

    {

    status = ++status; // инвертируем Статус

    }

    lastButten = currentButten; // Переприсваеваем прошлое состояние кнопки

     

     

    if (status == 10) //если статус 5

    {

    for (int i=0; i<11; i++){

    digitalWrite(ledPin,HIGH);

    delay(50);

    digitalWrite(ledPin,LOW);

    delay(50);

    }

    status = 0;

    }

    else // усди нажали не 5 раз выключаем светодиод

    {

    digitalWrite(ledPin,LOW);

    delay(20); // Ждем

    }

    }

     

     

    void qsan(){

    currentButten = debvance (lastButten); // Передаем функции дребезга значение по умолчанию LOW

    if (lastButten == LOW && currentButten == HIGH) // Проверяем отпускали мы кнопку или нет

    {

    status = ++status; // инвертируем Статус

    }

    lastButten = currentButten; // Переприсваеваем прошлое состояние кнопки

     

     

    if (status == 10) //если статус 5

    {

    for (int i=0; i<12; i++){

    digitalWrite(ledPin,HIGH);

    delay(50);

    digitalWrite(ledPin,LOW);

    delay(50);

    }

    status = 0;

    }

    else // усди нажали не 5 раз выключаем светодиод

    {

    digitalWrite(ledPin,LOW);

    delay(20); // Ждем

    }

    }

     

     

     

     

    void loop() {

      Key = 0;

      if ( ! rfid.PICC_IsNewCardPresent()) {goto empty;}// Поиск нового ключа

      if ( ! rfid.PICC_ReadCardSerial()) {goto empty;}// Выбор ключа

    for (byte i = 0; i < rfid.uid.size; i++){// Выдача серийного № ключа

    KeyTemp = rfid.uid.uidByte[i];

        Key = Key * 256 + KeyTemp;}

    empty:

      Serial.print("Card №: ");

      Serial.println(Key); // Выводим № ключа в консоль

     

     

     

     

    if( Key == 515280555){

    tas();

    }

     

     

    if( Key == 1459297918){

    qsan();

    }

     

     

    if (0 == Key){   // делаем когда метки нет

      in();

    }

     

     

    }

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube