y-matsui::weblog

電子楽器、音楽、コンピュータ、プログラミング、雑感。面倒くさいオヤジの独り言

RFIDリーダで遊ぶ〜LED点滅、フォーム色変更

RFIDキットのサンプルソースを眺める。
RFIDリーダが、受信イベントを発生する部分で、フォームの背景色をグリーン、LEDを点滅させたい。
出来た。

//Tag event handler...we'll display the tag code in the field on the GUI
void rfid_Tag(object sender, TagEventArgs e)
{
tagTxt.Text = e.Tag;
if (tagTxt.Text.Length > 0) {
Application.DoEvents();
tagTxt.BackColor = Color.Lime;
rfid.LED = true;
};
}

//Tag lost event handler...here we simply want to clear our tag field in the GUI
void rfid_TagLost(object sender, TagEventArgs e)
{
tagTxt.Text = "";
tagTxt.BackColor = Color.Gray;
rfid.LED = false;
}