set zero to millis

Hi :slight_smile: :slight_smile: :slight_smile: :slight_smile:
i have this and i want to set zero millis who i can do that???

#include <SPI.h>
#include <LiquidCrystal.h>
#include <SdFat.h>
#include <SdFatUtil.h>
#include <SFEMP3Shield.h>
SdFat sd;
SFEMP3Shield MP3player;

bool canchange= false;
int inputPin = 4;              
int pirState = LOW;            
int val = 0;                  
unsigned long time;
unsigned long allagikommatiou;

LiquidCrystal lcd(14, 15, 16, 17, 18, 19);//12, 11, 5, 4, 3, 2
//int8_t current_track = 1;

int tracknum=1;
int kinisi = 0;
long interval = 5000;
unsigned long currentMillis = 0;     // time variable to track running time: current time
unsigned long startingMillis = 0;    // time variable to track running time: starting time
byte result;

void setup() {
pinMode(inputPin, INPUT);    //vazoume ton sencora ws input

//ena minima gia tin lcd molis anoigei.....
if(!sd.begin(9, SPI_HALF_SPEED)) sd.initErrorHalt();
if (!sd.chdir("/")) sd.errorHalt("sd.chdir");

lcd.begin(16, 2);
lcd.print("eimai to junkbox");

void loop() {

allagikommatiou = millis();

if(allagikommatiou == 2000){
 allagikommatiou = 0 ;
 //prints time since program startedn

if(time >= 20000){
 lcd.setCursor(0, 0);
 Serial.println("Petaxe ena skoupidi");
 lcd.setCursor(0, 1);
 Serial.print("gia na paixw");
 kinisi = 0;



   // set the LED with the ledState of the variable:
   digitalWrite(inputPin, pirState);


if(tracknum == 10){
 Serial.println("xana apo thn arxh");
 tracknum = 0;

 val = digitalRead(inputPin);  // read input value
 if (val == HIGH) {            // check if the input is HIGH
   if (pirState == LOW) {
     Serial.print("Sensor 1: ");

     if(kinisi == 1){
     if(kinisi >= 1 && allagikommatiou >= 2000){
      canchange = true;
      Serial.println("mporei na allaxei kommati");
      allagikommatiou = 0;

     if(canchange == true){
      canchange = false;
     pirState = HIGH;        
 else {
   if (pirState == HIGH){
     pirState = LOW;

:o :o

Please use code tags (</> button on the toolbar) when you post code or warning/error messages. The reason is that the forum software can interpret parts of your code as markup, leading to confusion, wasted time, and a reduced chance for you to get help with your problem. This will also make it easier to read your code and to copy it to the IDE or editor. Using code tags and other important information is explained in the How to use this forum post. Please read it.

Please remove unnecessary blank lines from your code before posting to the forum. One or two to separate code into logical sections is fine but large spaces for no reason just make for more scrolling when we’re trying to read your code.

When your code requires a library that’s not included with the Arduino IDE please always post a link(using the chain link icon on the toolbar to make it clickable) to where you downloaded that library from or if you installed it using Library Manger(Sketch > Include Library > Manage Libraries) then say so and state the full name of the library.

i have this and i want to set zero millis who i can do that???

What does that even mean? Why would you want to do that?

“i want to set zero millis who i can do that???”

You shouldn’t need to do that.
Capturing two times with millis() or micros() and subtracting, laterTime - earlierTime, will tell you the elapsed time between them, even over a rollover, 0xFFFFFFF0 to 0x000000010 for example, 49.7 days for millis(), 71+ hours for micros().

<ok … i want to set 0 to millis because i want to reset the sensor …>

if(time >= 20000){
lcd.setCursor(0, 0);
Serial.println(“Petaxe ena skoupidi”);
lcd.setCursor(0, 1);
Serial.print(“gia na paixw”);
kinisi = 0;

and i want to reset the sensor for ‘‘MP3player.startTrack’’

I don't see MP3player.startTrack anywhere in your code.

You need to get this concept, it's very important. You should study File > Examples > 02.Digital > BlinkWithoutDelay and the associated tutorial page:

Until you understand every line of that sketch. Do you notice that the LED can keep blinking without ever setting millis() back to zero?