-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcodatech-rfid-test2.c
72 lines (61 loc) · 2 KB
/
codatech-rfid-test2.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#pragma config(Sensor, S1, CTRFID, sensorI2CCustom9V)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
/*
* $Id: codatech-rfid-test2.c 133 2013-03-10 15:15:38Z xander $
*/
/**
* codatech-rfid.h provides an API for the Codatex RFID sensor. This program
* demonstrates how to use that API to use the sensor in continuous mode.
*
* Changelog:
* - 0.1: Initial release
* - 0.2: Removed common.h include
*
* Credits:
* - Big thanks to Sylvain Cacheux for writing the initial drivers.
*
* License: You may use this code as you wish, provided you give credit where it's due.
*
* THIS CODE WILL ONLY WORK WITH ROBOTC VERSION 3.59 AND HIGHER.
* Xander Soldaat (xander_at_botbench.com)
* 20 february 2011
* version 0.2
*/
#include "drivers/codatech-rfid.h"
string transponderID;
task main()
{
nNxtButtonTask = -2;
nxtDisplayCenteredTextLine(0, "Codatex");
nxtDisplayCenteredBigTextLine(1, "RFID");
nxtDisplayCenteredTextLine(3, "Test 2");
nxtDisplayCenteredTextLine(5, "Connect sensor");
nxtDisplayCenteredTextLine(6, "to S1");
wait1Msec(2000);
eraseDisplay();
nxtDisplayCenteredTextLine(3, "Start single");
nxtDisplayCenteredTextLine(4, "reading loop");
wait1Msec(2000);
eraseDisplay();
// Set up the sensor for continuous readings.
CTRFIDsetContinuous(CTRFID);
// loop for transponder readings with continuous read function
while(nNxtButtonPressed == kNoButton) {
// read the transponder
if (!CTRFIDreadTransponder(CTRFID, transponderID)) {
eraseDisplay();
nxtDisplayTextLine(3, "Error reading");
nxtDisplayTextLine(4, "from sensor!");
wait10Msec(5000);
StopAllTasks();
}
nxtDisplayCenteredTextLine(3, "Transponder ID:");
nxtDisplayCenteredTextLine(4, "%s", transponderID);
// Be sure to add about 200ms after each read
// or you end up getting 0000000000 as a transponder address
wait1Msec(200);
}
}
/*
* $Id: codatech-rfid-test2.c 133 2013-03-10 15:15:38Z xander $
*/