[問題]該如何用arduino感測3個RFID read的訊號?

最近 因為需要使用RFID做出類似介面的裝置
而我現在想要在一個arduino上
裝入3個RFID read用來偵測個別的RFID tag訊號
而在最後同時顯示出3各別的訊號
像是: 0415ADAB82、0415AF5A82、0415AF0D27
而若之中有一組沒有的話則顯示空白

我在google上有找到相關資料
不過只能顯示出一組
程式碼如下
因為我是新手對程式也沒有概念
請各位可以給我指導嗎?
還有可以推薦我要撰寫Arduino這類的程式
從什麼地方下手或看什麼之類的書會比較有效率
謝謝
  1. #include <SoftwareSerial.h>

  2. #define rxPin 2
  3. #define txPin 3
  4. #define ledPin 13

  5. // set up a soft serial port
  6. SoftwareSerial mySerial(rxPin, txPin);

  7. int  val = 0;
  8. char code[10];
  9. int bytesread = 0;

  10. void setup() {
  11.   // define pin modes for tx, rx, led pins:
  12.   pinMode(rxPin, INPUT);    // Set rxPin as INPUT to accept SOUT from RFID pin
  13.   pinMode(txPin, OUTPUT);   // Set txPin as OUTPUT to connect it to the RFID /ENABLE pin
  14.   pinMode(ledPin, OUTPUT);  // Let the user know whats up

  15.   // set the data rate for the serial ports
  16.   mySerial.begin(2400);    // RFID reader SOUT pin connected to Serial RX pin at 2400bps
  17.   Serial.begin(9600);      // Serial feedback for debugging in Wiring

  18.   // say something
  19.   Serial.println("Hello World!");
  20. }

  21. void loop() {
  22.   digitalWrite(txPin, LOW);           // Activate the RFID reader
  23.   digitalWrite(ledPin, LOW);          // Turn off debug LED
  24.    
  25.   if((val = mySerial.read()) == 10) { // check for header
  26.     bytesread = 0;
  27.    
  28.     while(bytesread<10) {             // read 10 digit code
  29.       val = mySerial.read();
  30.       
  31.       if((val == 10)||(val == 13)) {  // if header or stop bytes before the 10 digit reading
  32.         break;                        // stop reading
  33.       }
  34.       
  35.       code[bytesread] = val;          // add the digit           
  36.       bytesread++;                    // ready to read next digit  
  37.     }
  38.    
  39.     if(bytesread == 10) {             // If 10 digit read is complete
  40.       digitalWrite(txPin, HIGH);      // deactivate RFID reader
  41.       digitalWrite(ledPin, HIGH);     // activate LED to show an RFID card was read
  42. //      Serial.print("TAG code is: ");  // possibly a good TAG
  43.       Serial.println(code);           // print the TAG code

  44.     }
  45.    
  46.     bytesread = 0;
  47.     delay(2000);                      // wait for a second to read next tag
  48.   }
  49. }
複製代碼
http://www.tekcrack.com/interfacing-arduino-with-parallax-rfid-reader-using-softwareserial.html

最近 因為需要使用RFID做出類似介面的裝置
而我現在想要在一個arduino上
裝入3個RFID read用來偵測個別的R ...
curitis 發表於 2010-4-4 16:46


你同時裝3個RFID reader用來偵測個別的RFID tag訊號?

佢地都係一齊駁入pin 2 & 3?

TOP

本帖最後由 curitis 於 2010-4-4 19:07 編輯

回復 2# Offer

是的,我要同時裝3個RFID reader來偵測個別的RFID tag訊號
我貼在上面的code是在網路上找的
我已經測試成功
但它是寫讀取一組的read
而我對Arduino 程式沒概念
不知道該怎麼去改寫,改成我所需要的
所輸入的訊號是要在個別的pin上
所以我想可能會有
3個rxpin與3個txpin
而這是我所想的,也不知道是否正確
還是能夠有別的方式能夠達到我要的目的
感謝

TOP

回復 2# Offer

我剛去看過你所發的文章
你用rfid來開電腦
厲害,我都沒想到這招

TOP

回復 3# curitis


本帖最後由 curitis 於 2010-4-4 19:07 編輯

回復 2# Offer


同時裝3個RFID reader來偵測個別的RFID tag訊號 ,係要使用RS485 interface先可以利用uart來做muti drop 駁埋一齊

TOP

回復 5# Offer


    這沒辦法從程式去讀取嗎?因為我手邊也沒有您所說得RS485 interface
    而且那些電子元件我就更不懂了....
    開始感覺一切沒我想像中的簡單

TOP

回復  Offer


    這沒辦法從程式去讀取嗎?因為我手邊也沒有您所說得RS485 interface
    而且那些電子 ...
curitis 發表於 2010-4-4 19:51



    不懂便開始去學


btw,其實你個設計為什麼要3個reader呢?

TOP

回復 7# Offer


    因為我是數位設計系的比較熟悉一些3D的軟體,
然後要做一個博物館雕塑家的導覽,因為我們有將他
的作品用紅外線掃描成3D物件.
再來我將導覽形式分成年代、材質以及他的作品系列
來分類所以共有三項,所以我才會用RFIR read來做裝
置而且最後收尋出來並不一定只有一個雕塑品,所以還
會在加入前後選單的操控,並且最後在用電子羅盤來
做雕塑品轉向的瀏覽.

而您說到要用RS485來做連結,是因為只有一個Serial Port
的問題嗎?

謝謝

TOP

回復  Offer


    因為我是數位設計系的比較熟悉一些3D的軟體,
然後要做一個博物館雕塑家的導覽,因為我們 ...
curitis 發表於 2010-4-4 20:44


要做一個博物館雕塑的導覽,所以每個RFIR reader的距離應該不會近吧
用RS485來做連結,是因為只有一個Serial Port及距離可以去到1200M,UART 的TTL Tx & Rx 只可去到幾M

TOP

回復 9# Offer


    其實每個read該說是距離不遠,因為同樣都會設置在一個展示台上
     我剛有想到若把3個read都接在同一個rx ping上,然後在控制時間
     範圍內去做判別

TOP