Hello,
I hope that somebody can help me with my code.
I have connected arduino+rdm6300+lcd display.
When the RFID tag is read, on the LCD screen is displayed the product name that belongs to a particular
RFID tag.
If I put a millis function, I know how the read time of tag can be displayed on the screen.
But I do not know how to achieve that when the first tag is read, LCD display the corresponding name of
the product and the read time of this product with a note Start time. When the second RFID tag is
read, the corresponding name of product is displayed on the LCD screen so as his reading time with a
note Finished time. Difference between Finished time and Start time is calculated and displayed on the
screen.
Then the Finished time of second read product (second read RFID tag) becomes the Start time of the
second read tag. When the third RFID tag is read, the corresponding name of product of third read
RFID tag is displayed on the LCD screen so as his reading time with a note Finished time. Difference
between Finished time and Start time is calculated and displayed on the screen. Then the Finished time
of this product product becomes the Start time of the third read product.
And so on...
My code is:
#include <SoftwareSerial.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); //postavlja LCD I2C adresu
SoftwareSerial RFID(10, 11); // RX and TX
// LED- to GND
// LED+ to pwm
int check_LED = -1;
int greenLED = 13;
int redLED = 12;
String tag1 = "25255484855685655567051503";
String tag2 = "25255484855685649695553673";
String tag3 = "25255484855685650665448693";
String tag4 = "25255484855685654674955683";
String tag5 = "25255484855685352515753553";
void setup() {
Serial.begin(9600);
//Serial.println("Serial Ready");
RFID.begin(9600);
//Serial.println("RFID Ready");
pinMode(greenLED, OUTPUT); // for status LEDs
Serial.println("Molimo provucite karticu za početak rada");
lcd.begin(20,4);
lcd.backlight(); //upaljena pozadina
lcd.setCursor(0,0); // Start at character 5 on line 0
lcd.print ("Molimo provucite karticu za pocetak rada");
delay(200);
lcd.setCursor(0,1);
}
void readTags()
{
int index =0 ;
int unit;
String msg;
while(RFID.available()>0)
{
unit = RFID.read();
index++;
msg += unit;
lcd.clear();
if(index == 14 && msg == tag1 )
{
Serial.println("Product1");
lcd.print("Product 1");
digitalWrite(greenLED, HIGH);
delay(1000);
digitalWrite(greenLED, LOW);
delay (1000);
}
else if (index == 14 && msg == tag2)
{
Serial.println("Product2");
lcd.print("Product2");
digitalWrite(greenLED, HIGH);
delay(1000);
digitalWrite(greenLED, LOW);
delay (1000);
}
else if (index == 14 && msg == tag3)
{
Serial.println("Product3");
lcd.print("Product3");
digitalWrite(greenLED, HIGH);
delay(1000);
digitalWrite(greenLED, LOW);
delay (1000);
}
else if (index == 14 && msg == tag4)
{
Serial.println("Product4");
lcd.print("Product 4");
digitalWrite(greenLED, HIGH);
delay(1000);
digitalWrite(greenLED, LOW);
delay (1000);
}
else if (index == 14 && msg == tag5)
{
Serial.println("Product5");
lcd.print("Product 5");
digitalWrite(greenLED, HIGH);
delay(1000);
digitalWrite(greenLED, LOW);
delay (1000);
}
}
}
void loop()
{
readTags();
}