我是剛觸碰Arduino跟VB的新手,想問各位高手們知道如何用VB.NET去讀取Arduino板的RFID卡的資料,我完全沒什麼頭緒要怎麼打,還請各位前輩指點! Arduino 的部分我參考了標機器人的程式碼! 而VB的部分我完全沒頭緒,請各位前輩指點! Arduino的程式碼: #include <SoftwareSerial.h> #define RFID_WRITE 0x02 #define RFID_READ 0x01 #define txPin 6 #define rxPin 8 SoftwareSerial mySerial(rxPin, txPin); int val; int runs = 0; void setup() { Serial.begin(9600); Serial.println("RFID Read/Write Test"); mySerial.begin(9600); pinMode(txPin, OUTPUT); pinMode(rxPin, INPUT); } void suppressAll() { if(mySerial.available() > 0) { mySerial.read(); suppressAll(); } } void loop(){ int val; mySerial.print("!RW"); mySerial.write(byte(RFID_READ)); mySerial.write(byte(32)); if(mySerial.available() > 0) { val = mySerial.read(); if (val != 1) {suppressAll();} } if(mySerial.available() > 0) { val = mySerial.read(); Serial.print(val, HEX); } if(mySerial.available() > 0) { val = mySerial.read(); Serial.print(val, HEX); } if(mySerial.available() > 0) { val = mySerial.read(); Serial.print(val, HEX); } if(mySerial.available() > 0) { val = mySerial.read(); Serial.print(val, HEX); } delay(750); } |
歡迎光臨 Robofun 機器人論壇 (https://robofun.net/forum/) | Powered by Discuz! X3.2 |