Вы находитесь на странице: 1из 4

ARDUINO RFID

20.10.2008 | Author: eb | Posted in Arduino

RFID (Radio Frequency Identification is a si!"#e and effecti$e %ay to trac& and identify !u#ti"#e unique ob'ects in a s"ace. (he !a'ority of sensor techno#o)ies do not su""ort trac&in) !u#ti"#e tar)ets* as %ith InfraRed or +#trasonic sensors. In these situations* the InfraRed or +#trasonic bea! %i## bounce off the nearest ob'ect and disre)ard anythin) behind the!. ,ith RFID* the iso#ation and identification of unique ob'ects is achie$ed by assi)nin) a distinct si)nature to each. RFID* a co!!on identification techno#o)y* can interface quite easi#y %ith !icrocontro##ers and co!"uters. RFID net%or&s require that both a RFID Reader and Passi$e or Acti$e RFID ta)s to function effecti$e#y. Passi$e ta)s )et their "o%er fro! the ener)y of the radio %a$e itse#f* as a resu#t Passi$e RFIDs on#y %or& o$er short distances. ,hereas* Acti$e ta)s are "o%ered $ia battery and can %or& o$er #ar)er distances. (he ID Inno$ations ID12 Reader is s#i)ht#y !ore co!"#e- than the Para##a- RFID* and o"erates at a faster baud rate . /000 b"s. A## the ID Inno$ations Readers use the sa!e co!!unication "rotoco#* and one can choose fro! three data out"ut for!ats . A12II* ,ei)and20 or 3a)netic (rac&. (he ta)s used in co##aboration %ith the ID12 are 435001 126 &78 ta)s* these ta)s encode the unique ID as A12II he-adeci!a# $a#ues. (herefore* %e %i## o"t for the A12II data out"ut for!at. (he Data 9utPut For!at . A12II 1(: (A12II 02 DA(A (10 A12II 2742; 1+3 (2 A12II 2R (A12II 1< =F (A12II 10 4(: (A12II 0<

(he co!!unication starts %ith a start>of>co!!unication (1(: byte (A12II 02 and ends %ith end>of>co!!unication (4(: byte (A12II 0< . (he 1(: byte is i!!ediate#y fo##o%ed by the ten>byte ta) ID (unique si)nature * a chec&su!* a carria)e return (A12II 1< * a #inefeed (A12II 10 and then the 4(: byte.

ID>12

ID12 Pin 1etu"


1 /* RFID reader ID-12 for <a 2 href="http://www.arduino.cc/play round/!ode/ID12" 3 tar et=""#lan$"%&rduino</a%

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

* 'a(ed on code #y <a href="http://people.interactioni)rea.it/h.#arra an" tar et=""#lan$"%'&RR&*&+</a% and <a href="http://hc il,e.wordpre((.co-/re(ource(/rfid"id12"ta reader/" tar et=""#lan$"%.! *il,e</a% * !hec$(u- #y <a href="http://www.-arti,nthe.nl/"%/arti,n</a% */ void setup() { // 0pen 1erial 2ort Serial.begin(9600) ! void loop () { b"te i # 0 b"te val # 0 b"te $ode%6& b"te $'e$(su) # 0 b"te b"tesread # 0 b"te te)pb"te # 0 i*(Serial.available() + 0) { // !hec$ for the 134 .eader 562 &1!II 7alue8 i*((val # Serial.read()) ## 2) { b"tesread # 0 // Read the RFID 16 di it code 9 the 2 di it chec$(u,'ile (b"tesread - 12) { i*( Serial.available() + 0) { val # Serial.read() // !hec$ for :34 ; 134 ; !R ; <F i*((val ## 0.0/)00(val ## 0.01)00(val ## 0.03)00(val ## 0.02)) { // 1top Readin - 3here i( an :rror. break ! // !on)ert .e= 3a ID i* ((val +# 202) 33 (val -# 292))

val # val 4 202 ! else i* ((val +# 212) 33 (val -# 252)) { val # 10 6 val 4 212 ! // :)ery two he=-di it(> add #yte to code: i* (b"tesread 3 1 ## 1) // -a$e (o-e (pace for thi( he=-di it #y // (hiftin the pre)iou( he=-di it with ? #it( to the left: $ode%b"tesread ++ 1& # (val 0 (te)pb"te -- 4)) i* (b"tesread ++ 1 7# 5)

{ // If we@re at the chec$(u- #yte> // !alculate the chec$(u-... 540R8 - :=clu(i)e 0R $'e$(su) 8# $ode%b"tesread ++ 1&

65 ! 66 ! 67 else 68 { 69 te)pb"te # val 70 ! 71 // ready to read ne=t di it 72 b"tesread66 73 ! 74 ! 75 76 // 2rint 77 i* (b"tesread ## 12) 78 { 79 Serial.print(954b"te $ode: 9) 80 *or (i#0 i-5 i66) 81 { 82 i* ($ode%i& - 16) Serial.print(909) 83 Serial.print($ode%i&; <=>) 84 Serial.print(9 9) 85 ! 86 Serial.println() 87 88 Serial.print(9?'e$(su): 9) 89 Serial.print($ode%5&; <=>) 90 Serial.println($ode%5& ## $'e$(su) @ 9 44 passed.9 : 9 44 91 error.9) 92 Serial.println() 93 ! 94 b"tesread # 0 ! ! !

Вам также может понравиться