PropWare
3.0.0.229
C++ objects and CMake build system for Parallax Propeller
Simple-Libraries
Learn
Examples
Devices
Sensor
RFID Serial
RFID Read and Compare.c
1
/*
2
RFID Read and Compare.c
3
4
After scanning your ID tags, you can copy their ID strings over the ones
5
in the else if statements in this program to recognize them.
6
7
Connect: Vcc to 5V, /ENABLE to P2, SOUT to (R = 2.2 k) to P1, GND to GND
8
9
http://www.parallax.com/product/28140
10
*/
11
12
#include "
simpletools.h
"
// Include simpletools
13
#include "
rfidser.h
"
// Include rfidser
14
15
int
rfidEn = 2;
// Reader /ENABLE pin
16
int
rfidSout = 1;
// Reader SOUT pin
17
18
rfidser *rfid;
// Set up device ID
19
20
int
main
()
// Main function
21
{
22
rfid =
rfid_open
(rfidSout, rfidEn);
// Open reader, start reading
23
24
while
(1)
// Main loop
25
{
26
char
*str =
rfid_get
(rfid, 1000);
// Wait up to 1 s for card
27
28
if
(!strcmp(str,
"timed out"
))
// Timed out?
29
print
(
"No ID scanned.\n"
);
// display "No ID..."
30
else
if
(!strcmp(str,
"02007D91ED"
))
// Tag A ID match?
31
print
(
"Tag A detected.\n"
);
// display "Tag A..."
32
else
if
(!strcmp(str,
"02007D9170"
))
// Tag B ID match?
33
print
(
"Tag B detected.\n"
);
// display "Tag B..."
34
else
// No matches?
35
print
(
"Unknown ID = %s.\n"
, str);
// print ID.
36
}
37
}
rfid_get
char * rfid_get(rfidser *device, int timeoutms)
Get RFID code from serial buffer.
Definition:
rfidser.c:125
rfidser.h
Simplifies reading Parallax Serial RFID Card Reader.
simpletools.h
This library provides convenient functions for a variety of microcontroller I/O, timing,...
print
int print(const char *format,...) __attribute__((format(printf
Print format "..." args to the default simple terminal device. The output is limited to 256 bytes.
main
int main(void)
Definition:
GraphicsTest.c:20
rfid_open
rfidser * rfid_open(int soutPin, int enablePin)
Runs the RFID card reading process in another cog.
Definition:
rfidser.c:20
Generated on Fri May 20 2022 16:48:04 for PropWare by
1.8.17