Robofun 機器人論壇

 找回密碼
 申請會員
搜索
熱搜: 活動 交友 discuz
查看: 3288|回復: 2
打印 上一主題 下一主題

Parallex RFID與arduino mega 1280

[複製鏈接]
跳轉到指定樓層
1#
發表於 2012-8-9 21:05:24 | 只看該作者 回帖獎勵 |倒序瀏覽 |閱讀模式
不知道有沒有人用過parallex出的RFID writer(不是reader)我使用它官網的範例
線也照接了
結果RFID卡一點反應也沒有(卡片也是parallex出的)

程式:
/****************************************************
//Code to write data to Parallax RFID reader/writer 28440 from Arduino//Program writes to one of the 29 user-defined addresses (3-31) as define by whichSpace//The four bytes to be written are defined by first, second, third, and fourth//Coded by vgrhcp, adapted to arduino 1.0 by sebflippers #include <SoftwareSerial.h> #define RFID_WRITE 0x02 #define txPin 6 #define rxPin 8 #define whichSpace 4 #define first 1                 // first, second, thrid, and fourth are four arbitrary values which will be written to the RFID tag at address whichSpace #define second 26 #define third 3 #define fourth 27SoftwareSerial mySerial(rxPin, txPin);void setup(){  Serial.begin(9600);  Serial.println("RFID Write Test");  mySerial.begin(9600);  pinMode(txPin, OUTPUT);       pinMode(rxPin, INPUT);      }void suppressAll()                                      //Keeps error code & the "write confirmation" codes from being printed in the serial monitor       {    if(mySerial.available() > 0)    { mySerial.read();      suppressAll();    }}  void loop(){  int val;  mySerial.print("!RW");  mySerial.write(byte(RFID_WRITE));  mySerial.write(byte(whichSpace));  mySerial.write(byte(first));  mySerial.write(byte(second));  mySerial.write(byte(third));  mySerial.write(byte(fourth));if(mySerial.available() > 0) {            val = mySerial.read();    if (val == 1)                                        //If data was written successfully      { Serial.println("Data written succesfully!");        suppressAll();      }    else suppressAll();                                  //If an error occured during writing, discard all data recieved from the RFID writer    }delay(250);}*************************************************************************************/接腳:VCC -> +5V (arduino)
SIN -> digital pin 6 (this is the txPin)
SOUT -> digital pin 8 (this is the rxPin)
GND -> GND (arduino)
我也是接數位接腳的6和8但是就是沒反應到底是怎麼回事
2#
 樓主| 發表於 2012-8-9 21:08:22 | 只看該作者
//Code to write data to Parallax RFID reader/writer 28440 from Arduino
//Program writes to one of the 29 user-defined addresses (3-31) as define by whichSpace
//The four bytes to be written are defined by first, second, third, and fourth
//Coded by vgrhcp, adapted to arduino 1.0 by sebflippers

#include <SoftwareSerial.h>
#define RFID_WRITE 0x02
#define txPin 6
#define rxPin 8

#define whichSpace 4

#define first 1                 // first, second, thrid, and fourth are four arbitrary values which will be written to the RFID tag at address whichSpace
#define second 26
#define third 3
#define fourth 27

SoftwareSerial mySerial(rxPin, txPin);

void setup()
{
  Serial.begin(9600);
  Serial.println("RFID Write Test");
  mySerial.begin(9600);
  pinMode(txPin, OUTPUT);     
  pinMode(rxPin, INPUT);      
}


void suppressAll()                                      //Keeps error code & the "write confirmation" codes from being printed in the serial monitor      
{
    if(mySerial.available() > 0)
    { mySerial.read();
      suppressAll();
    }
}

void loop()
{
  int val;

  mySerial.print("!RW");
  mySerial.write(byte(RFID_WRITE));
  mySerial.write(byte(whichSpace));
  mySerial.write(byte(first));
  mySerial.write(byte(second));
  mySerial.write(byte(third));
  mySerial.write(byte(fourth));

if(mySerial.available() > 0) {        
    val = mySerial.read();
    if (val == 1)                                        //If data was written successfully
      { Serial.println("Data written succesfully!");
        suppressAll();
      }
    else suppressAll();                                  //If an error occured during writing, discard all data recieved from the RFID writer
    }
delay(250);
}
3#
 樓主| 發表於 2012-8-9 21:11:36 | 只看該作者
上面是官網範例
但是不能用
您需要登錄後才可以回帖 登錄 | 申請會員

本版積分規則

小黑屋|手機版|Archiver|機器人論壇 from 2005.07

GMT+8, 2024-5-24 20:13 , Processed in 0.104654 second(s), 7 queries , Apc On.

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回復 返回頂部 返回列表