Can't create a library

Hello everyone.
I want to arrange my code, and along with this understand object oriented programming.

I want to wrap in a library my stepper motor code.
So, in Document->Arduino->Libraries I created a dedicated folder FreeMove

Inside it I created two files, FreeMove.h and FreeMove.cpp

FreeMove.h

#ifndef FreeMove_h
#define FreeMove_h
#include "Arduino.h" 
#include "AccelStepper.h"

class FreeMove {
public:
    FreeMove();
	void FreeMoveFunc(int StepsFreeMove);

};
#endif

FreeMove.cpp

#include "Arduino.h”
#include "FreeMove.h"
#include "AccelStepper.h"
FreeMove::FreeMove() {
}
void FreeMove::FreeMoveFunc(int StepsFreeMove){
  digitalWrite(enablePin,LOW); //enables motor

  stepperLevel.moveTo(StepsFreeMove);
  while((stepperLevel.currentPosition() != StepsFreeMove) && ( digitalRead(liftLimitSwitchUP) == LOW)) {
    stepperLevel.run();
  }
  digitalWrite(enablePin,HIGH); //enables motor

  delay(1000);
}  

The source code

#include <AccelStepper.h>

#include <FreeMove.h>

FreeMove UP();

// Define the stepper motor and the pins that is connected to
AccelStepper stepperLevel(1, 9, 10); // (Typeof driver: with 2 pins, STEP, DIR)


void setup() {
stepperLevel.setMaxSpeed(1000); // Set maximum speed value for the stepper
stepperLevel.setAcceleration(600); // Set acceleration value for the stepper
stepperLevel.setCurrentPosition(0); // Set the current position to 0 steps
}

void loop() {
UP.FreeMoveFunc(-300);
}

During compilation I got this error:

C:\Users\k\Documents\Arduino\robot_dec10\robot_dec10.ino: In function 'void loop()':
C:\Users\k\Documents\Arduino\robot_dec10\robot_dec10.ino:272:7: error: request for member 'FreeMoveFunc' in 'UP', which is of non-class type 'FreeMove()'
    UP.FreeMoveFunc(300);
       ^~~~~~~~~~~~

exit status 1

Compilation error: request for member 'FreeMoveFunc' in 'UP', which is of non-class type 'FreeMove()'

Honestly, I'm a new at all this stuff. Please, could you help me to find what's wrong.

And any other recommendations regarding the code itself are welcome.

Many thanks in advance!

Hi @konsmac. I suggest you check out the section on classes in this C++ programming tutorial:

https://cplusplus.com/doc/tutorial/classes/

Note that this is a general C++ tutorial, not specific to Arduino or embedded systems; written with the assumption that the reader is running the programs on a PC. This means that it contains some information that is not relevant for targeting a microcontroller. In order to follow the tutorial, you have to have some intuition about which parts are not relevant and the ability to either skip over them or mentally substitute the equivalent relevant information. But I think you will still find it to be a useful reference for your library project.

Your code contains a many errors. As mentioned @ptillisch , you need to read a basic textbook about class structure in C++

First of all, the lines

says that your class type name is FreeMove, so in Freemove.h it must be

Next - you can't use in a class method a variables, defined in your main .ino sketch, such as enablePin or stepperLevel . Every variable in the class code must be either a class member or send to the method as parameter.

This declares UP as a function returning a FreeMove object. It should be

FreeMove UP;