There is an error appearing

#include <IRremote.h>
#include <Adafruit_MotorShield.h>
#include <Wire.h>
#include <Servo.h>

// Define the IR remote codes
#define IR_ON_OFF 0xE11E7F80
#define IR_FORWARD 0xFA057F80
#define IR_LEFT 0xF8077F80
#define IR_RIGHT 0xF6097F80
#define IR_BACKWARD 0x58F8BCB2
#define IR_CAMERA_LEFT 0xF30C7F80
#define IR_CAMERA_RIGHT 0xFF007F80

// Initialize the Adafruit Motor Shield
Adafruit_MotorShield motorShield = Adafruit_MotorShield();
Adafruit_DCMotor *leftMotor = motorShield.getMotor(1);
Adafruit_DCMotor *rightMotor = motorShield.getMotor(2);

// Initialize the IR remote
IRrecv irrecv(11);
decode_results results;

// Initialize the servos
Servo horizontalServo;
int horizontalAngle = 90;

// Initialize the robot on/off state
boolean robotOn = false;

void setup() {
  // Initialize the serial port for debugging
  Serial.begin(9600);

  // Initialize the motor shield
  motorShield.begin();

  // Set the motor speeds to 0 initially
  leftMotor->setSpeed(0);
  rightMotor->setSpeed(0);

  // Start the IR remote receiver
  irrecv.enableIRIn();

  // Attach the servo to its pin
  horizontalServo.attach(9);

  // Set the initial angle for the servo
  horizontalServo.write(horizontalAngle);
}

void loop() {
  // Check if there is a new IR signal
  if (irrecv.decode(&results)) {
    // Print the received code for debugging
    Serial.println(results.value, HEX);

    // Check the received code and perform the appropriate action
    switch (results.value) {
      case IR_ON_OFF:
        // Turn the robot on or off

      if (robotOn) {
          // Turn off the robot
          leftMotor->setSpeed(0);
          rightMotor->setSpeed(0);
          robotOn = false;
        } else {
          // Turn on the robot

leftMotor->setSpeed(200);
          rightMotor->setSpeed(200);
          leftMotor->run(FORWARD);
          rightMotor->run(FORWARD);
          robotOn = true;
        }
        break;
      case IR_FORWARD:
        // Move the robot forward
        if (robotOn) {
          leftMotor->setSpeed(200);
          rightMotor->setSpeed(200);

      leftMotor->run(FORWARD);
          rightMotor->run(FORWARD);
        }
        break;
      case IR_LEFT:
        // Turn the robot left
        if (robotOn) {
          leftMotor->setSpeed(100);
          rightMotor->setSpeed(100);
          leftMotor->run(BACKWARD);
          rightMotor->run(FORWARD);
          }
        break;
      case IR_RIGHT:
        // Turn the robot right
        if (robotOn) {
          leftMotor->setSpeed(100);
          rightMotor->setSpeed(100);
          leftMotor->run(FORWARD);
          rightMotor->run(BACKWARD);
    }
break;
      case IR_BACKWARD:
        // Move the robot backward
        if (robotOn) {
          leftMotor->setSpeed(200);
          rightMotor->setSpeed(200);
          leftMotor->run(BACKWARD);
          rightMotor->run(BACKWARD);
        }
        break;
      case IR_CAMERA_LEFT:
        // Move the horizontal servo to the left

    if (robotOn && horizontalAngle > 0) {
          horizontalAngle--;
          horizontalServo.write(horizontalAngle);
        }
        break;
      case IR_CAMERA_RIGHT:
        // Move the horizontal servo to the right
        if (robotOn && horizontalAngle < 180) {
          horizontalAngle++;
          horizontalServo.write(horizontalAngle);
        }
        break;
      default:
        // Do nothing
        break;
    }

      // Wait a moment and then clear the IR signal buffer
    delay(200);
    irrecv.resume();
  }
    }

And this is the error that appears, knowing that I installed all libraries from within the application, and when it appeared that this library needs to install other libraries, he agreed to install them

/sdk/hardware/tools/avr/bin/avr-g++ -no-canonical-prefixes -std=gnu++11 -c -g -Os -w -mmcu=atmega328p -DF_CPU=16000000L -DUSB_VID=null -DUSB_PID=null -DARDUINO=10812 -DIDE="ArduinoDroid" -DARDUINO_ARCH_AVR -DARDUINO_AVR_UNO /libraries/Servo/src/avr/Servo.cpp -o /librariesBuild/Servo/avr_Servo.cpp.o /sdk/hardware/tools/avr/bin/avr-g++ -no-canonical-prefixes -std=gnu++11 -c -g -Os -w -mmcu=atmega328p -DF_CPU=16000000L -DUSB_VID=null -DUSB_PID=null -DARDUINO=10812 -DIDE="ArduinoDroid" -DARDUINO_ARCH_AVR -DARDUINO_AVR_UNO /libraries/Servo/src/sam/Servo.cpp -o /librariesBuild/Servo/sam_Servo.cpp.o /sdk/hardware/tools/avr/bin/avr-g++ -no-canonical-prefixes -std=gnu++11 -c -g -Os -w -mmcu=atmega328p -DF_CPU=16000000L -DUSB_VID=null -DUSB_PID=null -DARDUINO=10812 -DIDE="ArduinoDroid" -DARDUINO_ARCH_AVR -DARDUINO_AVR_UNO /libraries/Servo/src/stm32f4/Servo.cpp -o /librariesBuild/Servo/stm32f4_Servo.cpp.o /sdk/hardware/tools/avr/bin/avr-g++ -no-canonical-prefixes -std=gnu++11 -c -g -Os -w -mmcu=atmega328p -DF_CPU=16000000L -DUSB_VID=null -DUSB_PID=null -DARDUINO=10812 -DIDE="ArduinoDroid" -DARDUINO_ARCH_AVR -DARDUINO_AVR_UNO /libraries/Servo/src/nrf52/Servo.cpp -o /librariesBuild/Servo/nrf52_Servo.cpp.o /sdk/hardware/tools/avr/bin/avr-g++ -no-canonical-prefixes -std=gnu++11 -c -g -Os -w -mmcu=atmega328p -DF_CPU=16000000L -DUSB_VID=null -DUSB_PID=null -DARDUINO=10812 -DIDE="ArduinoDroid" -DARDUINO_ARCH_AVR -DARDUINO_AVR_UNO /libraries/Servo/src/samd/Servo.cpp -o /librariesBuild/Servo/samd_Servo.cpp.o /sdk/hardware/tools/avr/bin/avr-g++ -no-canonical-prefixes -std=gnu++11 -c -g -Os -w -mmcu=atmega328p -DF_CPU=16000000L -DUSB_VID=null -DUSB_PID=null -DARDUINO=10812 -DIDE="ArduinoDroid" -DARDUINO_ARCH_AVR -DARDUINO_AVR_UNO /Adafruit_BusIO/Adafruit_BusIO_Register.cpp -o /librariesBuild/Adafruit_BusIO/Adafruit_BusIO_Register.cpp.o /sdk/hardware/tools/avr/bin/avr-g++ -no-canonical-prefixes -std=gnu++11 -c -g -Os -w -mmcu=atmega328p -DF_CPU=16000000L -DUSB_VID=null -DUSB_PID=null -DARDUINO=10812 -DIDE="ArduinoDroid" -DARDUINO_ARCH_AVR -DARDUINO_AVR_UNO /Adafruit_BusIO/Adafruit_I2CDevice.cpp -o /librariesBuild/Adafruit_BusIO/Adafruit_I2CDevice.cpp.o /sdk/hardware/tools/avr/bin/avr-g++ -no-canonical-prefixes -std=gnu++11 -c -g -Os -w -mmcu=atmega328p -DF_CPU=16000000L -DUSB_VID=null -DUSB_PID=null -DARDUINO=10812 -DIDE="ArduinoDroid" -DARDUINO_ARCH_AVR -DARDUINO_AVR_UNO /Adafruit_BusIO/Adafruit_SPIDevice.cpp -o /librariesBuild/Adafruit_BusIO/Adafruit_SPIDevice.cpp.o /sdk/hardware/tools/avr/bin/avr-g++ -no-canonical-prefixes -std=gnu++11 -c -g -Os -w -mmcu=atmega328p -DF_CPU=16000000L -DUSB_VID=null -DUSB_PID=null -DARDUINO=10812 -DIDE="ArduinoDroid" -DARDUINO_ARCH_AVR -DARDUINO_AVR_UNO /Adafruit_Motor_Shield_V2_Library/Adafruit_MotorShield.cpp -o /librariesBuild/Adafruit_Motor_Shield_V2_Library/Adafruit_MotorShield.cpp.o /Adafruit_Motor_Shield_V2_Library/Adafruit_MotorShield.cpp:33:40: fatal error: Adafruit_MS_PWMServoDriver.h: No such file or directory
 #include <Adafruit_MS_PWMServoDriver.h>
                                        ^
compilation terminated.
Return code is not 0

It looks like you didn't

Well, what should I do? And this file is already inside the library, and I also searched for it a lot, but I couldn't find it.

There are contradiction options in compile command line.

If your board is Uno and mcu is atmega328:

why do you try to compile with STM libraries

It seems to me that there is something wrong in your Arduino IDE configuration.
Did you tried to add libraries and headers manually?

No, I didn't try adding it manually

Who created the programme?

Hi,
What model Arduino are you writing code for?

Thanks.. Tom.. :smiley: :+1: :coffee: :australia:

Arduino UNO R3 SMD CH340G And installed in it Adafruit Motor /Stepper /Servo Shield for Arduino v2.3 board

A crucial detail you did not mention:

Adafruit_MS_PWMServoDriver.h is in the utility directory of the motor shield library and apparently ArduinoDroid does not handle it correcly.

The sketch compiles fine with iDE 1.8.19 and arduino-cli 0.32.2.

Thank you for your interest.
If i do this with IDE 1.8.19 as you mentioned, will work correctly?

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