element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • 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 & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
    About the element14 Community
  • 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
      •  Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      •  Vietnam
      • 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 Re: Have a question about Arduino? Ask me!
  • 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 1 reply
  • Subscribers 416 subscribers
  • Views 337 views
  • Users 0 members are here
Related

Re: Have a question about Arduino? Ask me!

e14 Contributor
e14 Contributor over 12 years ago

At: Re: Have a question about Arduino? Ask me!

archisman wrote:

 

> Thanks for the code man....those two lines really helped...

 

Glad to hear it!


> now I am facing a new problem...when I am trying to display the larger of the two counts its displaying the correct value but it keeps on displaying it line after line...


The loop() function is special in Arduino.  You aren't allowed to return from it because there's nowhere

to return to.  You can probably figure out a workaround.  Maybe put all your code as a normal loop in

the setup() function, or use an empty infinite loop in place of returning from loop().


  • Sign in to reply
  • Cancel
  • e14 Contributor
    e14 Contributor over 12 years ago

    Hi there..I am trying out a simple program of matching RFID tags..however it is showing wrong tag even when I am holding up the right one...wat am I doig wrong...the code is posted below...somebody please help...thanksin advance...

     

    int count = 0; // A variable to count the length of the Tag DATA

    char tag[]="19729083";

    char input[10];

    boolean flag=0;

    boolean state=0;

    void setup()

    {

      Serial.begin(9600); // Initialize Serial Communication - Both with the RFID reader & the Serial Monitor

     

     

    }

     

     

    void loop()

    {

     

      if(Serial.available()) // Check if there is Incoming Data in the Serial Buffer. This is data coming from the RFID reader

      {

        count = 0; // Reset count to zero

        while(Serial.available() && count<10) // Keep reading Byte by Byte from the Buffer till the Buffer is empty

        {

          input[count] = Serial.read(); // Read 1 Byte of data and store it in the input[] variable

          count++; // increment counter

          delay(5);

        }

       

        Serial.println(input);//it is displaying the exact number that I stored,even then its showing wrong tag

        Serial.println(count);

       

        if(count ==10)// When the counter reaches 12 (the size of the ID) we stop and compare each value of the input[] to the corresponding stored value

        {

          count =0; // reset counter varibale to 0

          flag = 1;

          while(count<10 && flag !=0) // Iterate through each value and compare till either the 12 values are all matching or till the first mistmatch occurs

          {

            if(input[count]==tag[count])

            flag = 1; // everytime the values match, we set the flag variable to 1

            else

            flag=0; // if the ID values don't match, set flag variable to 0 and stop comparing by exiting the while loop

            count++; // increment i

          }

        }

            if(flag == 1) // If flag variable is 1, then it means the tags match

        {

          Serial.println("Matched!");

              }

        else

        {

          Serial.println("Wrong Tag"); // Incorrect Tag Message

        }

      

        for(count=0; count<10; count++) // Fill the input variable array with a fixed value 'F' to overwrite all values getting it empty for the next read cycle

          {

            input[count]= 'F';

          }

         count = 0; // Reset counter variable 

      }

    }

    • 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 © 2026 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.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube