Is there a way for me to pause my code in the middle of the two if statements so I can scan the second RFID so the code can continue on to the second if statement with the information from the second RFID? -
// Using Arduino Uno and RFIDs RC522
-
#include <require_cpp11.h>
-
#include <MFRC522.h>
-
#include <deprecated.h>
-
#include <MFRC522Extended.h>
-
-
#include <SPI.h>
-
#include <MFRC522.h>
-
#define SS_PIN 10
-
#define RST_PIN 9
-
MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance.
-
int count = 0;
-
int greenLED = 5;
-
int redLED = 6;
-
int yellowLED = 7;
-
-
void setup()
-
{
-
pinMode(greenLED, OUTPUT);
-
pinMode(redLED, OUTPUT);
-
pinMode(yellowLED, OUTPUT);
-
-
-
Serial.begin(9600); // Initiate a serial communication
-
SPI.begin(); // Initiate SPI bus
-
mfrc522.PCD_Init(); // Initiate MFRC522
-
Serial.println("Approximate your card to the reader...");
-
Serial.println();
-
-
}
-
void loop()
-
{
-
// Look for new cards
-
if ( ! mfrc522.PICC_IsNewCardPresent())
-
{
-
return;
-
}
-
// Select one of the cards
-
if ( ! mfrc522.PICC_ReadCardSerial()) {
-
-
return;
-
}
-
//Show UID on serial monitor
-
-
Serial.print("UID tag :");
-
String content= "";
-
byte letter;
-
for (byte i = 0; i < mfrc522.uid.size; i++) {
-
-
-
Serial.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " ");
-
Serial.print(mfrc522.uid.uidByte[i], HEX);
-
content.concat(String(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " "));
-
content.concat(String(mfrc522.uid.uidByte[i], HEX));
-
-
}
-
Serial.println();
-
//Serial.print("Message : ");
-
content.toUpperCase();
-
int count = 0;
-
-
if (content.substring(1) == "89 E7 75 47") //change here the UID of the card/cards that you want to give access
-
{
-
Serial.println("Authorized access");
-
Serial.println();
-
digitalWrite(yellowLED, HIGH);
-
delay(1000);
-
digitalWrite(yellowLED, LOW);
-
-
count = count + 1;
-
}
-
-
else {
-
Serial.println(" Access denied");
-
Serial.println();
-
digitalWrite(redLED, HIGH);
-
delay(1000);
-
digitalWrite(redLED, LOW);
-
-
-
if (content.substring(2) == "F9 9A 76 47")
-
{
-
Serial.println("Authorized access");
-
Serial.println();
-
digitalWrite(yellowLED, HIGH);
-
delay(1000);
-
digitalWrite(yellowLED, LOW);
-
count = count + 1;
-
}
-
else {
-
Serial.println(" Access denied");
-
Serial.println();
-
digitalWrite(redLED, HIGH);
-
delay(1000);
-
digitalWrite(redLED, LOW);
-
}
-
-
if (count == 2 ) {
-
Serial.println(" Done");
-
Serial.println();
-
digitalWrite(greenLED, HIGH);
-
delay(3000);
-
digitalWrite(greenLED, LOW);
-
-
}
-
-
}
-
}
-
2 1322 Luuk 1,047
Expert 1GB
Is that not solved by a 'standard' while statement? -
do
-
{
-
// whatever
-
} while ( !condition );
-
The condition is, in this case, 'scan second RFID succeeded'.
I am not sure what you mean by "pause the code". The execution will always be stopped on using any function that requires user attention like inputs etc.
How is the "scan the second RFID" thing done? If that is something provided by the user, just insert the appropriate function between the two ifs. If that's something returned by a library function, just call that function after the first if. The program execution is sequential. Since you want the info of the second RFID before the second if, just make a way to fetch that info before going to the second if.
And then the code can continue on to the second if statement with the information of the second RFID.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: NotGiven |
last post by:
I need to loop through some code but pause each time for about 1 second.
how do I do this? Thanks.
|
by: MLH |
last post by:
Best way to make Access 2.0 code wait 10 seconds before processing the
next line???
For i=1 to whatever : next i
is just too processor intensive.
Isn't there something less taxing
I can...
|
by: 466 |
last post by:
/// headerfile; definition file for BBB class
template <class CORE>
class BBB : public CORE {};
/// another header file
class AAA;
template <class AAAclass BBB;
|
by: OldSchool |
last post by:
Good day!
I have problem dealing with Data recieving through use of RFID scanner. the Scenario is this, im going to scan the RFID and I will Recieved a Data from it and i will compare it in...
|
by: Ronald S. Cook |
last post by:
I'm wanting to scan all folders and files under a specified path (e.g.
C:\Files). I know using System.IO I can use Directory.GetFiles to get a
list of files under a folder, but how do I get the...
|
by: =?Utf-8?B?Tkg=?= |
last post by:
Hi,
I am looking for some code that would scan a folder structure and files in
those folders and display them on a web page so that people can click on the
file links and open the files. There...
|
by: Tark Siala |
last post by:
hi
i'm using VS.NET 2005 +SP1 C#, and i connect access database by ADO.NET 2.0.
i'm using Dataset to (insert,update,delete) and in get data i use
(Datareader), but my problem when i do this:
1 -...
|
by: zyborg33 |
last post by:
I am updating records in 2 tables, Employees and Projects with a new value for NAMEPHONE
The code fails on the second update in one sub
Private Sub cmdNewName_Click()
Dim conDatabase As...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |