millis not working

kindly any anybody helps as project

delay_timer_programming_17-5-19.ino (741 Bytes)

i can't see your code on my device as it will not recognise ino files. Post the code as directed by the how to use this forum~please read sticky so that everyone can see it.

It's easier for people if you post code using code tags like this:

int ledPin = 13;
int ledend = 12;
int last = 0;
int m = 0;


void setup() {
  pinMode(ledPin, OUTPUT);
  pinMode(ledend, OUTPUT);
  Serial.begin(9600);
}
void loop() {
  while (Serial.available() == 0); {
    int value = Serial.read() - '0';
    int j = 100;
    for (int i = millis(); i > j; i++) {
      if (value == 1) {
        digitalWrite(ledPin, HIGH);
        m = millis(); -last;
        if ( millis() > last + 15000) {
          Serial.print ("Timer has ended ");
          digitalWrite(ledend, HIGH);
          last = millis();
          break;
        }
      }
    }
    if (value == 0)
    {
      digitalWrite(ledPin, LOW);
      digitalWrite(ledend, LOW);
      Serial.flush();
    }
  }
}

This looks really odd: for (int i = millis(); i > j; i++)
As does this:       m = millis(); -last;

Maybe if you told us what you want the sketch to do, and tell us what happens when it runs.

I'd recommend you add some serial.Print() statements to "look at", what serial.Available() is returning and to see if "value" is what you expect.

Sometimes it's helpful to add little messages like "Starting while() loop" or anything that helps you to see what the program is doing.

And otherwise - Simplify your code until something works and then "develop" your code one or two lines at a time, test-compiling and test-running as you go.

    int j = 100;
    for (int i = millis(); i > j; i++) {

A tenth of a second after boot has completed, the condition in the for loop will always be true (well, for quite a while anyway).

millis returns an unsigned long, not an int.

Is that what you intended?
I suspect not.

millis not working

Please be assured that that statement is false.

AWOL:

    int j = 100;

for (int i = millis(); i > j; i++) {


A tenth of a second after boot has completed, the condition in the for loop will always be true (well, for quite a while anyway).

millis returns an unsigned long, not an int.


Is that what you intended?
I suspect not.
Please be assured that that statement is false.

kindly tell how to reset millis

vijayanand:
kindly tell how to reset millis

Kindly tell why you would want to.
(It is embarrassingly simple (or used to be), but no-one ever does)

Often people post and say that such a command is not working. The truth is that they are always wrong. These functions always work, it is just that you don’t know how to use them.

If you think you want to reset the millis timer then you are doing it all wrong.

Look at the examples in this thread, or this one, or work through the Blink Without Delay example in the IDE.

It's important to learn how to use timekeeping in order to write Arduino code effectively.

how to create code kindly tell

We're not psychic.

vijayanand:
how to create code kindly tell

Open the IDE and start typing.

For any more help a lot of detail about of what the code is supposed to do will be required.

Steve