Round -Stoppwatch with RFID and LCD

Hey guys, Im completly new in this forum and i hope that I write in the right part of it.

In our school we have a project, with the Arduino 2560 Mega, RFID RC522 and an LC-Display as basic.
So, our project assignment is, to build a stopwatch with RIFD Chips as start and stop taster.
And on the Display we should shown the time of each round.

So we can stop the lap time, of more then one Runner with an RFID chip. So basically we found out that we can measure time with the command millis. But our problem is, that we can’t show the right time on the display. Here is our code at the actual status:

#include <SPI.h>
#include <MFRC522.h>
#define SS_PIN 53
#define RST_PIN 26
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
int LED=22;
int Pieps=24;
MFRC522 mfrc522(SS_PIN, RST_PIN);
unsigned long start, finished, elapsed;

void setup()

{
Serial.begin(9600);
SPI.begin();
mfrc522.PCD_Init();
pinMode(LED, OUTPUT);
pinMode(Pieps,OUTPUT);
lcd.begin(16, 2);
}

void loop()

/RFID Shiet/

{
if ( ! mfrc522.PICC_IsNewCardPresent())
{

}
if ( ! mfrc522.PICC_ReadCardSerial())
{
return;
}
for (byte i = 0; i < mfrc522.uid.size; i++)
{
Serial.print(mfrc522.uid.uidByte*, HEX);*
Serial.print(" ");
}
Serial.print(“Die ID des RFID-TAGS lautet:”);
/* LCD teil*/

  • start=millis();*
  • delay(200); // for debounce*
  • Serial.println(“Started…”);*
    float h,m,s,ms;
  • unsigned long over;*
  • elapsed=finished-start;*
  • h=int(elapsed/3600000);*
  • over=elapsed%3600000;*
  • m=int(over/60000);*
  • over=over%60000;*
  • s=int(over/1000);*
  • ms=over%1000;*
    digitalWrite(LED, HIGH);
    digitalWrite(Pieps, HIGH);
    lcd.setCursor(0, 0);
    lcd.print(“Zeit”);
    lcd.setCursor(0, 1);
    lcd.println(elapsed);
    lcd.print("VZeit: ");
    lcd.print(m,0);
    lcd.print("m ");
    lcd.print(s,0);
    lcd.print("s ");
    lcd.println();
    delay(1000);
    digitalWrite(LED, LOW);
    digitalWrite(Pieps, LOW);
    delay(1000);
  • {*
  • finished=millis();*
  • delay(200); // for debounce*
  • }*
    }
    We hope, that erveryone can help us here with the coding, because we are only Hardware Guys and are really bad at coding or something :smiley:
    Thanks, Jannik

Hi

What is the exact problem with showing the time on the display.

Daniel

It is showing the millis instead of the Seconds, hours and minutes.

Lg Jannik

Hi Jannik

I think I have found your problem:

You wrote

lcd.print(m,0);

I think you want that on the Display appears m,0 (m as the value of your m).

if you write

lcd.print(m);
lcd.print(",0");
lcd.print("m ");

it works.

Now you just have to do this with s again and it should work.

Daniel

Sorry, but it doesnt work... Same problem as beginning.

We want on the display the layout

TIME_RunnnerID HH:MM:SS:MSMS

But Thanks for your reply

Jannik

I suspect there is a problem with the code shown on the screen. It turns italic in the middle of the sketch for no apparent reason, and we all know what [u]that[/u] means! If you use code tags, as shown in the "How to use this forum" post, that problem should clear up.

Right, first things first.

Go and read the instructions, then go back and modify your post (use the "More --> Modify" option to the bottom right of the post) to mark up the code as such so we can examine it conveniently and accurately.

As has been demonstrated, if you do not do this, your code may well be meaningless as it is here.

Note: Also mark up any data in the same way. This includes error output that you get from the IDE.

Sorry i edit it…

#include <SPI.h>
#include <MFRC522.h>
#define SS_PIN 53
#define RST_PIN 26
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
int LED=22;
int Pieps=24;
MFRC522 mfrc522(SS_PIN, RST_PIN);
unsigned long start, finished, elapsed;

void setup()

{
Serial.begin(9600);
SPI.begin();
mfrc522.PCD_Init();
pinMode(LED, OUTPUT);
pinMode(Pieps,OUTPUT);
lcd.begin(16, 2);
}



void loop()

/*RFID Shiet*/

{
if ( ! mfrc522.PICC_IsNewCardPresent())
{
 
}
if ( ! mfrc522.PICC_ReadCardSerial())
{
return;
}
for (byte i = 0; i < mfrc522.uid.size; i++)
{
Serial.print(mfrc522.uid.uidByte, HEX);
Serial.print(" ");
}
Serial.print("Die ID des RFID-TAGS lautet:");

/* LCD teil*/

  start=millis();
    delay(200); // for debounce
    Serial.println("Started...");
float h,m,s,ms;
  unsigned long over;
  elapsed=finished-start;
  h=int(elapsed/3600000);
  over=elapsed%3600000;
  m=int(over/60000);
  over=over%60000;
  s=int(over/1000);
  ms=over%1000;
digitalWrite(LED, HIGH);
digitalWrite(Pieps, HIGH);
lcd.setCursor(0, 0);
lcd.print("Zeit");
lcd.setCursor(0, 1);
lcd.println(elapsed);
lcd.print("VZeit: ");
lcd.print(m,0);
lcd.print("m ");
lcd.print(s,0);
lcd.print("s ");
lcd.println();
delay(1000);
digitalWrite(LED, LOW);
digitalWrite(Pieps, LOW);
delay(1000);


  {
    finished=millis();
    delay(200); // for debounce
  }
}

JanNik368: Sorry I edit it...

OK, now edit your first post.