Robofun 機器人論壇

標題: VB.NET去控制RFID卡的問題? [打印本頁]

作者: k940714675    時間: 2013-7-9 10:40
標題: VB.NET去控制RFID卡的問題?
本帖最後由 k940714675 於 2013-7-9 20:26 編輯

我是剛觸碰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);

}

作者: k940714675    時間: 2013-7-9 15:24
vb的程式碼只知道:
Imports System.IO
Imports System.IO.Ports
Imports System.Threading
Public Class Form1
    Shared _serialport As SerialPort
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        SerialPort1.Close()
        SerialPort1.PortName = "com3"
        SerialPort1.BaudRate = 9600
        SerialPort1.DataBits = 8
        SerialPort1.Parity = Parity.None
        SerialPort1.StopBits = StopBits.One
        SerialPort1.Handshake = Handshake.None
        SerialPort1.Encoding = System.Text.Encoding.Default
    End Sub

    Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click
   
    End Sub
End Class




歡迎光臨 Robofun 機器人論壇 (https://robofun.net/forum/) Powered by Discuz! X3.2