now i want to compare the value .for example i am having two tags of dif values(say 08160978 & 08201290)..i want to assign dif opertioon with respect to the tag.....so i want to compare the serial value from reader....so wat shud i do nw?
ERROR:its showing as "incompatible types in assignment of int to int[8]"
C:\Program Files\Arduino\hardware\arduino\cores\arduino/Print.h:75: note: size_t Print::println(long unsigned int, int)
I think what you find on this Forum is that people are willing to point you in the right direction, but would prefer that you learn from the experience, rather than just providing an answer. It is a give-a-man-fish versus teach-a man-how-to-fish thing. Further, no one really cares that you have a deadline coming up...we all have deadlines. That said, in your statement:
a = mySerial.read();
What do you think the variable a is? a is viewed by the compiler as the memory address of where the array named a is stored in memory. Let's assume that the compiler has placed your array at memory location 1000. If the byte coming in from read() is, let's say the character '0' (zero), that has an ASCII value of 48. So, your statement is trying to change the memory address of a from 1000 to 48. The memory address of a variable, also called its lvalue, is constant and the compiler rightly will not let you change it.
As a hint, the statement:
a[index] = mySerial.read();
says to take the byte just read and assign it into element a[index] of the array. Now go read the references what were given to you and I think you'll be able to better figure things out.
#include <SoftwareSerial.h>
SoftwareSerial mySerial(8,9); // RX, TX
int A[8];
int i;
void setup()
{
Serial.begin(9600);
while (!Serial)
{
;
}
Serial.println("rfid identity value!");
mySerial.begin(9600);
}
void loop()
{
if(mySerial.available())
{
for (i = 0; i < 8; i++ )
{
A[i] = mySerial.read();
delay(500);
}
Serial.println(A[4]);
delay(1000);
}
}
now the value of A[4] is dipalyed as-1 48 -1 (read many times same tag).without that 2 delays i got some continuous -1 -1 -1 -1 irespective of the tag.
if(mySerial.available())
{
for (i = 0; i < 8; i++ )
{
A[i] = mySerial.read();
delay(500);
See if there's at least one character to read, then go ahead and read all eight of them.
That's why you "need" the delay.
Why not check to see if there's something to read, before reading it?
.