parallaxのrfidリーダーを使って便利な物を作りたいと思っています。
arduino初心者です。
よろしくお願いします。
http://playground.arduino.cc/Learning/PRFID
上記のサイトにサンプルコードがあったのでこちらを少し変更して、簡単な物をつくりたいと思っています。
そこで、最初に タグコード 650012BA4D が読まれたら、シリアルモニターにYESと表示させる。としたいと思い、下記のようにスケッチしたのですが、
sketch_apr15a.ino:44:18: error: invalid suffix "BA4D" on integer constant
とエラーが出てしまいます。
エラーの原因は何でしょうか?
スケッチ
#include <SoftwareSerial.h>
int val = 0;
char code[10];
int bytesread = 0;
#define rxPin 8
#define txPin 9
// RFID reader SOUT pin connected to Serial RX pin at 2400bps to pin8
void setup()
{
Serial.begin(2400); // Hardware serial for Monitor 2400bps
pinMode(2,OUTPUT); // Set digital pin 2 as OUTPUT to connect it to the RFID /ENABLE pin
digitalWrite(2, LOW); // Activate the RFID reader
}
void loop()
{
SoftwareSerial RFID = SoftwareSerial(rxPin,txPin);
RFID.begin(2400);
if((val = RFID.read()) == 10)
{ // check for header
bytesread = 0;
while(bytesread<10)
{ // read 10 digit code
val = RFID.read();
if((val == 10)||(val == 13))
{ // if header or stop bytes before the 10 digit reading
break; // stop reading
}
code[bytesread] = val; // add the digit
bytesread++; // ready to read next digit
}
if(bytesread == 10) { // if 10 digit read is complete Serial.print("TAG code is: "); // possibly a good TAG Serial.println(code); // print the TAG code if(code == 650012BA4D) { Serial.print("YES"); } else { Serial.print("NO"); } } bytesread = 0; delay(500); // wait for a second
}
}
どなたかご存知の方よろしくお願い致します。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2015/04/15 14:10
2015/04/15 14:13
2015/04/15 14:26
2015/04/15 14:46
2015/04/15 14:57