Track amount of time spend on office tasks

I would like to make a device measuring the length of my office tasks in minutes.

I'm thinking of using a potentiometer that alligns with different values, for example:

  1. Offline
  2. Replying e-mails
  3. Making new offers
  4. Driving from customer to customer
  5. Administration
  6. Break
  7. etc.

When set on a value the time in minutes need to be measured and stored.
Can someone helps me with the setup? Just my first project.

Open up the IDE and under "File" open up "Examples".
There should be one that shows you how to read a voltage off an analogue input pin.

The input I can get working, but don't know how to start timing and record the outcome line by line

You really don't know how to measure relative time?

millis() returns the the current 1/1000 of a second.

I know something about millis, but not how to write code on it for Arduino. Can I count how many miliseconds the value of the potentiometer was between 400 and 500?

Use millis in the classic blink without delay manner to read the pot occasionally. Once a minute perhaps.

Have a bunch of variables that count time for each activity. When you read the pot, increment whichever variable it tells you to. If statements will let you figure out which one.

Then scrap all those variables and use an array instead :grinning:

start with simple push buttons.
one button for each office task.
If you start on task - press the button.

Well. If you know "something" about millis() than this sketch might help.

// https://forum.arduino.cc/t/millis-timer-pausieren-und-wieder-starten/855936
// by noiasca
// 2021-05-01

int8_t activeTimer = -1;                     // stores the active Timer ID

class Timer {
  protected:
    const byte buttonPin;                    // pin to GND starts timer
    uint32_t previousMillis = 0;             // last active millis of this timer
    uint32_t myMillis = 0;                    // accumlated millis for this timer
    const byte id;                           // give each object an ID
    static byte total;                       // keep track of the number of timer objects

  public:
    Timer (byte buttonPin): buttonPin(buttonPin), id (total++)
    {}

    void begin()
    {
      pinMode(buttonPin, INPUT_PULLUP);
    }

    void read()  // read button and if different button, activate timer
    {
      if (digitalRead(buttonPin) == LOW && activeTimer != id) activateTimer();
    }

    void activateTimer()                                     // sets timer i to active
    {
      previousMillis = millis();
      activeTimer = id;
      Serial.print(F("Button pressed ")); Serial.println(id);
    }

    uint32_t getMillis()                                     // returns the accumulated millis of one timer
    {
      if (activeTimer == id)                                 // update millis before return
      {
        uint32_t currentMillis = millis();
        myMillis += currentMillis - previousMillis;          // add passed time to old millis
        previousMillis = currentMillis;                      // remember the timestamp of the last millis update
      }
      return myMillis;
    }

    byte getId()
    {
      return id;
    }

    void pauseTimer(uint32_t currentMillis = millis())       // pause an active Timer, either with parameter or actual millis() will be used
    {
      if (activeTimer == id)                                 // update millis before return
      {
        myMillis += currentMillis - previousMillis;          // add passed time to old millis
        previousMillis = currentMillis;                      // remember the timestamp of the last millis update - optional
      }
    }
};

byte Timer::total = 0;           // declare inside class, but define outside = 0 (leave it 0!)

Timer timer[] {
  {A0},                          // buttonPin
  {A1}
};

const byte pausePin = A3;

void setup() {
  Serial.begin(115200);
  Serial.println(F("Stopwatch"));
  for (auto &i : timer) i.begin();
  pinMode(pausePin, INPUT_PULLUP);
}

void loop() {
  // read button
  for (auto &i : timer)
    i.read();
  readPause();
  // output
  updateSerial();
}

void updateSerial()                                                 // demo output to serial
{
  static uint32_t previousMillis = 0;
  uint32_t currentMillis = millis();
  if (millis() - previousMillis >= 500)
  {
    for (auto &i : timer)
    {
      Serial.print(F("Timer")); Serial.print(i.getId()); Serial.print(" "); Serial.print(i.getMillis()); Serial.print("\t");
    }
    Serial.print(F(" active=")); Serial.println(activeTimer);
    previousMillis = currentMillis;
  }
}

void readPause()
{
  if (digitalRead(pausePin) == LOW && activeTimer != -1)
  {
    timer[activeTimer].pauseTimer();
    activeTimer = -1;
    Serial.println(F("timer paused"));
  }
}

if you connect buttons to Analog0 and Analog1 you can see how this is working for two timeslots.
There is a global "pause" on Analog3 currently.
You should be able to expand that example for more timers, it's just one line for each additional timer.