PropWare
C++ objects and CMake build system for Parallax Propeller
Home
Download
Getting Started
Documentation
Reference
About
Related Links
Namespace List
Class List
File List
Examples
Build System
File List
File Members
propsideworkspace
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
}
main
int main(void)
Definition:
GraphicsTest.c:20
Generated on Sat Aug 27 2016 00:58:03 for PropWare by
1.8.12