hello guys, i'm making system read 2 rfid on same arduino.
i have code , need detect when serial read not available.
it works right on original rx input on simulated input never go "else", ever "available"
here code:
util informations !!
\/
i'm using reset on pin 13 , 2 rfid wired on same reset
i'm using id-20 innovation
i have code , need detect when serial read not available.
it works right on original rx input on simulated input never go "else", ever "available"
here code:
code: [select]
#include <softwareserial.h>
softwareserial id20(3,2);
int rfidresetpin = 13;
string tagstring;
string p2;
boolean dentro = false;
boolean dentro2 = true;
void setup(){
serial.begin(9600);
id20.begin(9600);
pinmode(rfidresetpin, output);
digitalwrite(rfidresetpin, high);
pinmode(5, output);
}
void loop()
{
delay(500);
readproduto1();
readproduto2();
resetreader();
}
void readproduto1()
{
char tagchar = 0;
if(serial.available())
{
while(serial.available())
{
tagchar = serial.read();
if (ishexadecimaldigit(tagchar))
{
tagstring += tagchar;
}
else
{
if (tagstring.length() > 0)
{
dentro = true;
serial.println(tagstring);
tagstring = "";
}
}
}
}
else
{
serial.println("saiu1");
}
resetreader();
}
void readproduto2()
{
char produto2 = 0;
if(id20.available()>0)
{
while(id20.available())
{
produto2 = id20.read();
if(ishexadecimaldigit(produto2))
{
p2 += produto2;
}
else
{
if(p2.length() > 0)
{
dentro2 = true;
serial.println(p2);
p2 = "";
}
}
}
}
//----------------------------------it never gets \/---------------------------------
else
{
serial.println("saiu2");
}
//----------------------------------------------------------------------------------------------
resetreader();
}
void resetreader()
{
digitalwrite(rfidresetpin, low);
digitalwrite(rfidresetpin, high);
}
util informations !!
\/
i'm using reset on pin 13 , 2 rfid wired on same reset
i'm using id-20 innovation
quote
i have code , need detect when serial read not available.the softwareserial class has available() method that.
put every { on new line.
put every } on new line. none of crap:
code: [select]
}else{
it's impossible tell else "it never gets to" paired with.
Arduino Forum > Using Arduino > Programming Questions > Reading 2 RFID on same arduino
arduino
Comments
Post a Comment