Help: RFID and serLCD
hey,
i new arduino , products 1 of friends @ university got me it, , using uni project.
i using serial enabled lcd seeeduino ( backpack (http://littlebirdelectronics.com/products/serial-enabled-lcd-backpack) , normal 2x16 5v lcd screen attached) , rfid module (http://littlebirdelectronics.com/products/125khz-rfid-module-uart).
i have got both code of these elements working on own, internet, struggling them work together.
i not sure issue is. stops working when include lcd coding, including lcd.begin etc.
at moment trying make lcd output value of rfid card.
thanks in advance!
willing read have throw @ me!
i new arduino , products 1 of friends @ university got me it, , using uni project.
i using serial enabled lcd seeeduino ( backpack (http://littlebirdelectronics.com/products/serial-enabled-lcd-backpack) , normal 2x16 5v lcd screen attached) , rfid module (http://littlebirdelectronics.com/products/125khz-rfid-module-uart).
i have got both code of these elements working on own, internet, struggling them work together.
i not sure issue is. stops working when include lcd coding, including lcd.begin etc.
at moment trying make lcd output value of rfid card.
thanks in advance!
willing read have throw @ me!
code: [select]
#include <softwareserial.h>
softwareserial rfid = softwareserial(2, 2);
softwareserial lcd = softwareserial(0, 3);
const int lcddelay=100;
void lcdposition(int row, int col)
{
lcd.write(0xfe); //command flag
lcd.write((col + row*64 + 128)); //position
delay(lcddelay);
}
void clearlcd()
{
lcd.write(0xfe); //command flag
lcd.write(0x01); //clear command.
delay(lcddelay);
}
void backlighton()
{ //turns on backlight
lcd.write(0x7c); //command flag backlight stuff
lcd.write(157); //light level.
delay(lcddelay);
}
void backlightoff()
{ //turns off backlight
lcd.write(0x7c); //command flag backlight stuff
lcd.write(128); //light level off.
delay(lcddelay);
}
void sercommand()
{ //a general function call command flag issuing other commands
lcd.write(0xfe);
}
void setup()
{
pinmode(3, output);
serial.begin(9600);
rfid.begin(9600);
lcd.begin(9600); // maximum bandwidth issue
}
void loop()
{
receiverfidcardinfo();
}
void receiverfidcardinfo()
{
static byte data[4];
static byte temp[14];
byte len;
static int = 0;
unsigned long currentid;
if(rfid.available())
{
temp[i++] = rfid.read();
if(14 == i)
{
if( 0x02 == temp[0] && 0x03 == temp[13])
{
data[0] = transform(temp[3])*16 + transform(temp[4]);
data[1] = transform(temp[5])*16 + transform(temp[6]);
data[2] = transform(temp[7])*16 + transform(temp[8]);
data[3] = transform(temp[9])*16 + transform(temp[10]);
currentid = (unsigned long)data[0]*16777216 + (unsigned long)data[1]*65536 + (unsigned long)data[2]*256 + (unsigned long)data[3];
serial.println("\ncurrentid:");
serial.print(currentid,dec);
i=0;
clearlcd();
lcdposition(0,0);
lcd.print(currentid, dec);
}
}
}
}
byte transform(byte dat)
{
if(dat >= 0x30 && dat <= 0x39)
{
return (dat - 0x30);
}else if(dat >= 0x41 && dat <= 0x46)
{
return (dat - 55);
}
}
code: [select]
softwareserial rfid = softwareserial(2, 2);do have tx pin of rfid connected same arduino pin rx pin? that's unusual way of doing things.
code: [select]
softwareserial lcd = softwareserial(0, 3);using hardware serial pin softwareserial bad idea.
code: [select]
void loop()
{
receiverfidcardinfo();
}why?
code: [select]
void receiverfidcardinfo()
{
static byte data[4];
static byte temp[14];
byte len;
static int = 0;
unsigned long currentid;
if(rfid.available())
{
why data , temp static? why static?
looks forgot put rfid in listen mode.
code: [select]
currentid = (unsigned long)data[0]*16777216 + (unsigned long)data[1]*65536 + (unsigned long)data[2]*256 + (unsigned long)data[3];bit shifting more efficient.
code: [select]
if(dat >= 0x30 && dat <= 0x39)
{
return (dat - 0x30);
}else if(dat >= 0x41 && dat <= 0x46)
{
return (dat - 55);
}what's magic numbers? why mix of hex , decimal?
Arduino Forum > Using Arduino > Project Guidance > Help: RFID and serLCD
arduino
Comments
Post a Comment