I am new to arduino and i am having this error in code, can anyone help me resolve it

'''
#include <AS5600.h>
#include <L298N.h>

// Define motor pins
#define INA 2
#define INB 3
#define ENA 5

// Define encoder pins
#define ENC_CS_PIN 10
#define ENC_PWM_PIN 11

// Define balancing constants
#define KP 2.0
#define KI 0.5
#define KD 0.5

// Initialize the motor driver
L298N motor(INA, INB, ENA);

// Initialize the encoder
AS5600 encoder(ENC_CS_PIN, ENC_PWM_PIN);
:_enc(ENC_CS_PIN, ENC_PWM_PIN);

// Initialize the PID variables
double pid_error = 0;
double pid_integral = 0;
double pid_derivative = 0;
double pid_setpoint = 0;
double pid_output = 0;
double pid_last_error = 0;

// Initialize the reaction wheel variables
double reaction_wheel_speed = 0;
double reaction_wheel_position = 0;

void setup() {
// Initialize serial communication
Serial.begin(9600);

// Initialize the motor driver
motor.begin();

// Initialize the encoder
encoder.begin();
encoder.setZeroPosition();

// Set the PID setpoint to 0
pid_setpoint = 0;
}

void loop() {
// Get the current position of the reaction wheel
reaction_wheel_position = encoder.getPosition();

// Calculate the current speed of the reaction wheel
reaction_wheel_speed = (reaction_wheel_position - pid_last_error) / 0.001;

// Calculate the error between the current position and the setpoint
pid_error = pid_setpoint - reaction_wheel_position;

// Calculate the integral of the error
pid_integral += pid_error * 0.001;

// Calculate the derivative of the error
pid_derivative = (pid_error - pid_last_error) / 0.001;

// Calculate the output of the PID controller
pid_output = KP * pid_error + KI * pid_integral + KD * pid_derivative;

// Set the speed of the motor to the PID output
motor.setSpeed(pid_output);

// Update the last error
pid_last_error = pid_error;

// Print the current position and speed of the reaction wheel
Serial.print("Position: ");
Serial.print(reaction_wheel_position);
Serial.print(", Speed: ");
Serial.println(reaction_wheel_speed);

// Wait for 1 millisecond
delay(1);
}
'''
error:
Arduino: 1.8.19 (Windows 10), Board: "Arduino Uno"

C:\Program Files (x86)\Arduino\arduino-builder -dump-prefs -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -hardware C:\Users\Sambhaji\AppData\Local\Arduino15\packages -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -tools C:\Users\Sambhaji\AppData\Local\Arduino15\packages -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries C:\Users\Sambhaji\Documents\Arduino\libraries -fqbn=arduino:avr:uno -vid-pid=2341_0043 -ide-version=10819 -build-path C:\Users\Sambhaji\AppData\Local\Temp\arduino_build_757622 -warnings=none -build-cache C:\Users\Sambhaji\AppData\Local\Temp\arduino_cache_350337 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.arduinoOTA.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.arduinoOTA-1.3.0.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avr-gcc.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avr-gcc-7.3.0-atmel3.6.1-arduino7.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avrdude.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avrdude-6.3.0-arduino17.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -verbose C:\Users\Sambhaji\Documents\Arduino\as5600_chatgpt_eample\as5600_chatgpt_eample.ino

C:\Program Files (x86)\Arduino\arduino-builder -compile -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -hardware C:\Users\Sambhaji\AppData\Local\Arduino15\packages -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -tools C:\Users\Sambhaji\AppData\Local\Arduino15\packages -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries C:\Users\Sambhaji\Documents\Arduino\libraries -fqbn=arduino:avr:uno -vid-pid=2341_0043 -ide-version=10819 -build-path C:\Users\Sambhaji\AppData\Local\Temp\arduino_build_757622 -warnings=none -build-cache C:\Users\Sambhaji\AppData\Local\Temp\arduino_cache_350337 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.arduinoOTA.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.arduinoOTA-1.3.0.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avr-gcc.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avr-gcc-7.3.0-atmel3.6.1-arduino7.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avrdude.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avrdude-6.3.0-arduino17.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -verbose C:\Users\Sambhaji\Documents\Arduino\as5600_chatgpt_eample\as5600_chatgpt_eample.ino

Using board 'uno' from platform in folder: C:\Program Files (x86)\Arduino\hardware\arduino\avr

Using core 'arduino' from platform in folder: C:\Program Files (x86)\Arduino\hardware\arduino\avr

Detecting libraries used...

"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10819 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\standard" "C:\Users\Sambhaji\AppData\Local\Temp\arduino_build_757622\sketch\as5600_chatgpt_eample.ino.cpp" -o nul

Alternatives for AS5600.h: [AS5600@0.3.6]

ResolveLibrary(AS5600.h)

-> candidates: [AS5600@0.3.6]

"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10819 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\standard" "-IC:\Users\Sambhaji\Documents\Arduino\libraries\AS5600" "C:\Users\Sambhaji\AppData\Local\Temp\arduino_build_757622\sketch\as5600_chatgpt_eample.ino.cpp" -o nul

Alternatives for Wire.h: [Wire@1.0]

ResolveLibrary(Wire.h)

-> candidates: [Wire@1.0]

"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10819 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\standard" "-IC:\Users\Sambhaji\Documents\Arduino\libraries\AS5600" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src" "C:\Users\Sambhaji\AppData\Local\Temp\arduino_build_757622\sketch\as5600_chatgpt_eample.ino.cpp" -o nul

Alternatives for L298N.h: [L298N@2.0.3]

ResolveLibrary(L298N.h)

-> candidates: [L298N@2.0.3]

"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10819 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\standard" "-IC:\Users\Sambhaji\Documents\Arduino\libraries\AS5600" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src" "-IC:\Users\Sambhaji\Documents\Arduino\libraries\L298N\src" "C:\Users\Sambhaji\AppData\Local\Temp\arduino_build_757622\sketch\as5600_chatgpt_eample.ino.cpp" -o nul

"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10819 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\standard" "-IC:\Users\Sambhaji\Documents\Arduino\libraries\AS5600" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src" "-IC:\Users\Sambhaji\Documents\Arduino\libraries\L298N\src" "C:\Users\Sambhaji\Documents\Arduino\libraries\AS5600\AS5600.cpp" -o nul

"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10819 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\standard" "-IC:\Users\Sambhaji\Documents\Arduino\libraries\AS5600" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src" "-IC:\Users\Sambhaji\Documents\Arduino\libraries\L298N\src" "C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\Wire.cpp" -o nul

"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10819 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\standard" "-IC:\Users\Sambhaji\Documents\Arduino\libraries\AS5600" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src" "-IC:\Users\Sambhaji\Documents\Arduino\libraries\L298N\src" "C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c" -o nul

"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10819 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\standard" "-IC:\Users\Sambhaji\Documents\Arduino\libraries\AS5600" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src" "-IC:\Users\Sambhaji\Documents\Arduino\libraries\L298N\src" "C:\Users\Sambhaji\Documents\Arduino\libraries\L298N\src\L298N.cpp" -o nul

"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10819 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\standard" "-IC:\Users\Sambhaji\Documents\Arduino\libraries\AS5600" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src" "-IC:\Users\Sambhaji\Documents\Arduino\libraries\L298N\src" "C:\Users\Sambhaji\Documents\Arduino\libraries\L298N\src\L298NX2.cpp" -o nul

Generating function prototypes...

"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10819 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\standard" "-IC:\Users\Sambhaji\Documents\Arduino\libraries\AS5600" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src" "-IC:\Users\Sambhaji\Documents\Arduino\libraries\L298N\src" "C:\Users\Sambhaji\AppData\Local\Temp\arduino_build_757622\sketch\as5600_chatgpt_eample.ino.cpp" -o "C:\Users\Sambhaji\AppData\Local\Temp\arduino_build_757622\preproc\ctags_target_for_gcc_minus_e.cpp"

"C:\Program Files (x86)\Arduino\tools-builder\ctags\5.8-arduino11/ctags" -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives "C:\Users\Sambhaji\AppData\Local\Temp\arduino_build_757622\preproc\ctags_target_for_gcc_minus_e.cpp"

Compiling sketch...

"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10819 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\standard" "-IC:\Users\Sambhaji\Documents\Arduino\libraries\AS5600" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src" "-IC:\Users\Sambhaji\Documents\Arduino\libraries\L298N\src" "C:\Users\Sambhaji\AppData\Local\Temp\arduino_build_757622\sketch\as5600_chatgpt_eample.ino.cpp" -o "C:\Users\Sambhaji\AppData\Local\Temp\arduino_build_757622\sketch\as5600_chatgpt_eample.ino.cpp.o"

as5600_chatgpt_eample:22:39: error: no matching function for call to 'AS5600::AS5600(int, int)'

AS5600 encoder(ENC_CS_PIN, ENC_PWM_PIN);

                                   ^

In file included from C:\Users\Sambhaji\Documents\Arduino\as5600_chatgpt_eample\as5600_chatgpt_eample.ino:1:0:

C:\Users\Sambhaji\Documents\Arduino\libraries\AS5600/AS5600.h:89:3: note: candidate: AS5600::AS5600(TwoWire*)

AS5600(TwoWire *wire = &Wire);

^~~~~~

C:\Users\Sambhaji\Documents\Arduino\libraries\AS5600/AS5600.h:89:3: note: candidate expects 1 argument, 2 provided

C:\Users\Sambhaji\Documents\Arduino\libraries\AS5600/AS5600.h:86:7: note: candidate: constexpr AS5600::AS5600(const AS5600&)

class AS5600

   ^~~~~~

C:\Users\Sambhaji\Documents\Arduino\libraries\AS5600/AS5600.h:86:7: note: candidate expects 1 argument, 2 provided

C:\Users\Sambhaji\Documents\Arduino\libraries\AS5600/AS5600.h:86:7: note: candidate: constexpr AS5600::AS5600(AS5600&&)

C:\Users\Sambhaji\Documents\Arduino\libraries\AS5600/AS5600.h:86:7: note: candidate expects 1 argument, 2 provided

as5600_chatgpt_eample:23:1: error: expected unqualified-id before ':' token

:_enc(ENC_CS_PIN, ENC_PWM_PIN);

^

C:\Users\Sambhaji\Documents\Arduino\as5600_chatgpt_eample\as5600_chatgpt_eample.ino: In function 'void setup()':

as5600_chatgpt_eample:42:9: error: 'class L298N' has no member named 'begin'

motor.begin();

     ^~~~~

as5600_chatgpt_eample:46:11: error: 'class AS5600' has no member named 'setZeroPosition'; did you mean 'setZPosition'?

encoder.setZeroPosition();

       ^~~~~~~~~~~~~~~

       setZPosition

C:\Users\Sambhaji\Documents\Arduino\as5600_chatgpt_eample\as5600_chatgpt_eample.ino: In function 'void loop()':

as5600_chatgpt_eample:54:37: error: 'class AS5600' has no member named 'getPosition'; did you mean 'getZPosition'?

reaction_wheel_position = encoder.getPosition();

                                 ^~~~~~~~~~~

                                 getZPosition

Using library AS5600 at version 0.3.6 in folder: C:\Users\Sambhaji\Documents\Arduino\libraries\AS5600

Using library Wire at version 1.0 in folder: C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire

Using library L298N at version 2.0.3 in folder: C:\Users\Sambhaji\Documents\Arduino\libraries\L298N

exit status 1

no matching function for call to 'AS5600::AS5600(int, int)'

Can you please edit your post to put your code back between code tags as it seems to have escaped from them.

I'm guessing that by the folder & file name of the sketch, that you probably didn't write this code yourself?

Do you have any of the libraries installed that the sketch requires to run?

Press Ctrl + t in the IDE code editor and copy the code.

Press image and paste the code where highlighted

These are libraries that need to be included with your project. Have you downloaded or installed these or other libraries?

Can you explain what to do with the 2 lines?
I think they have the wrong syntax.
Where did you find this code?

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.