Chronometer

I'm trying to make a fully working chronometer with the addition of using a self made library.
I made a fully working code before starting to split my functions into a library, after having finished that I tried to compile my code again after a quick restart of the Arduino IDE.

the error log states the following:

C:\Users\bjorn\OneDrive\APHogeschool\2EA\Microcontrollers\Lab4_Opg4\Lab4_Opg4.ino:1:25: fatal error: Chronometer.h: No such file or directory

#include "Chronometer.h"

^

compilation terminated.

exit status 1
Fout bij het compileren voor board Arduino Nano

main .ino code:

#include "Chronometer.h"

Chronometer chronometer(100);
const int light[] = {3, 4, 5, 6, 7, 8, 9};
const int digit[] = {10, 11, 12, 13};
int value[] = {0, 0, 0, 0};
bool change[] = {true, false, false, false};
int hold[] = {0, 0, 0, 0};
const int table[][7] = {
  {1, 1, 1, 1, 1, 1, 0},
  {0, 1, 1, 0, 0, 0, 0},
  {1, 1, 0, 1, 1, 0, 1},
  {1, 1, 1, 1, 0, 0, 1},
  {0, 1, 1, 0, 0, 1, 1},
  {1, 0, 1, 1, 0, 1, 1},
  {1, 0, 1, 1, 1, 1, 1},
  {1, 1, 1, 0, 0, 0, 0},
  {1, 1, 1, 1, 1, 1, 1},
  {1, 1, 1, 1, 0, 1, 1}
};


void setup() {
  // put your setup code here, to run once:
  for (int i = 0; i < 7; i++) {
    pinMode(light[i], OUTPUT);
  }
  for (int i = 0; i < 7; i++) {
    pinMode(digit[i], OUTPUT);
    digitalWrite(digit[i], HIGH);
  }
  Serial.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly:
  for (int d = 0; d < 4; d++) {
    digitalWrite(digit[d], LOW);
    chronometer.Convert(light, value, d, change);
    digitalWrite(digit[d], HIGH);
  }
  int d = 0;
  hold[d]++;
  while (d < 4) {
    chronometer.Change(value, d, change);
    d++;
  }
}

.h code

#ifndef Morse_h
#define Morse_h

#include "Arduino.h"

class Chronometer {
  public:
    Chronometer(int timestamp);
    void Convert(int light[], int value[], int d, bool change[]);
    void Change(int value[], int d, bool change[]);
  private:
    int _timestamp;
};

#endif

.cpp code

#include "Arduino.h"
#include "Chronometer.h"

Chronometer::Chronometer(int timestamp) {
  _timestamp = timestamp;
}
void Chronometer::Convert(int light[], int value[], int d, bool change[]) {
  for (int j = 0; j < 7; j++) {
    digitalWrite(light[j], table[value[d]][j]);
  }

  delay(3);
}

void Chronometer::Change(int value[], int d, bool change[]) {
  if (hold[d] == timestamp) {
    value[d]++;
    if (d != 0)
      hold[d] = 0;
    if (value[0] == 10) {
      value[0] = 0;
      hold[1] = timestamp;
    }
    if (value[1] == 6) {
      value[1] = 0;
      hold[2] = timestamp;
    }
    if (value[2] == 10) {
      value[2] = 0;
      hold[3] = timestamp;
    }
    if (value[3] == 6) {
      value[3] = 0;
      hold[4] = timestamp;
    }
    hold[d] = 0;
  }
}

thanks.

Not going to download a zip file. You will get more help if you post the code as instructed in the "how to use the forum-please read" stickies. Specifically #7 of this post.

Student660:
I've attached the file and library folder that I'm using.

are both the .h and .cpp files in the same directory as the .ino file?

BulldogLowell:
are both the .h and .cpp files in the same directory as the .ino file?

No, the .h and .cpp files are in the arduino/libraries folder, the main .ino file is saved in my documents
have tried putting them together but this did not help

Student660:
No, the .h and .cpp files are in the arduino/libraries folder

did you then try:

#include <Chronometer.h>

or add tabs in the IDE and past your library's .h and .cpp into two new tabs like this:

BulldogLowell:
or add tabs in the IDE and past your library's .h and .cpp into two new tabs like this:

this seems to work but I run into problems with my array now, atleast the library issue is solved.

Thanks for the help

Student660:
...but I run into problems with my array now...

yes, that's quite a kludge of global variables intertwined with your class...

what are you actually trying to do there?

plus some cut/paste relics:

#ifndef Morse_h
#define Morse_h

BulldogLowell:
what are you actually trying to do there?

//these initialize the pins I'm using for the LED display
const int light[] = {3, 4, 5, 6, 7, 8, 9};
const int digit[] = {10, 11, 12, 13};

//this holds the value of each indiviual number to be displayed
int value[] = {0, 0, 0, 0};

//this is was the only way I was able to make sure only the numbers that have to be changed actually change
bool change[] = {true, false, false, false};

//this checks passed time, I could change this to a single integer but it works fine like this
int hold[] = {0, 0, 0, 0};

//this is a translation table that ensures the right parts of the 7 segment LED display light up
int _table[10][7] = {
  {1, 1, 1, 1, 1, 1, 0},
  {0, 1, 1, 0, 0, 0, 0},
  {1, 1, 0, 1, 1, 0, 1},
  {1, 1, 1, 1, 0, 0, 1},
  {0, 1, 1, 0, 0, 1, 1},
  {1, 0, 1, 1, 0, 1, 1},
  {1, 0, 1, 1, 1, 1, 1},
  {1, 1, 1, 0, 0, 0, 0},
  {1, 1, 1, 1, 1, 1, 1},
  {1, 1, 1, 1, 0, 1, 1}
};

and the timestamp could just be a number but I wanted it to be easy to change the interval between each digit change.

But I fixed most problems with my messy code, seems to be working fine now appart from the fact that part a of my LEDs won't light up, if you have a way to make a more organized code, I would love to hear it.

//these initialize the pins I'm using for the LED display

I can read the code, I was asking what you were trying to do... with the code.

Student660:
...seems to be working fine now appart from the fact that part a of my LEDs won't light up...

are they supposed to light up? if so, do you really mean it is working fine?

BulldogLowell:
are they supposed to light up? if so, do you really mean it is working fine?

My LED display is counting again after making the library so the problem I had is fixed.

The top LED is also working again, fixed it in the worst way possible by initializing another pin before the other important pins, bit stupid but it works.