I am trying to make a simple IR sensor shooting game

I only have a rough draft of some code I got from a tutorial but every time I hit verify it keeps giving me library issues(among others). I only have access to Arduino ide 2.0.4 and Arduino 1.8.19 because my school won't let us download any later or earlier versions. I was able to work out one of the library issues but then there was a bunch more more

I have the
robot IR remote
IR remote
Servo
libraries(currently)

the parts

  • currently its a uno but it is going to be switched for a nano

  • for the ir sensor brand it is a Alinan

  • the servo is a sg90

  • for the ir sensor i do not know the specifics because I did not buy them so I would not know where to look(sorry) ,I do know that it looks a lot like this type. images

  • my IR remote is just a elegoo remote I also did not buy it so I do not know where to look. It does however look like this type
    Screenshot 2024-05-08 120042

  • and a tm1687 seven segment display to display points but that can be ignored for now

the goal for the code is to make a Arduino IR shooting game with six targets(different target will add different point amounts). the elegoo remote (for right now) will be clicked by someone playing and then the the IR sensor will detect a signal from the remote and then the corresponding (each target has one IR sensor and one servo) sg90 servo motor will "fall"(move) backwards it will stay at this position for a second(maybe less) and then move back to is original position and while all of this is happening (if i can get the code for the servo working) there will be a tm1687 seven segment display that detects every time a target(ir+sg90 servo grouping) is "hit" (detects a signal) and will add a point with the help of a point counting code ( that I hopefully can find premade, but for right now we are going to ignore it unless that would make it harder later or something) for displaying the points

this is a schematic of what I have currently wired
Screenshot 2024-05-08 132104
(I can change the ports if there is some better order)
this is what I want it too look like in the ideal scenario(this is with the tm1687 display but again I think it better if I just ignore it for now)


this is what I think is attainable

the pin connections are 100% flexible but here are the ones in the picture there are the same across the board not counting the difference in the number of components:
IR sensor 1 in wired to A0. Servo 1 is wired to D13
IR sensor 2 is wired to A1. Servo 2 is wired to D12
IR sensor 3 is wired to A2. Servo 3 is wired to D11
IR sensor 4 is wired to A3. Servo 4 is wired to D10
IR sensor 5 is wired to A4. Servo 5 is wired to D9
IR sensor 6 is wired to A5. Servo 6 is wired to D8
the TM1687 DIO pin is wired to D7
the TM1687 CLK pin is wired to D6
the numbers assigned to each component represent one grouping(target). the matching numbers are for which motor should be controlled by which IR sensor.

when powering it the main target is not going to move so i think i am just gonna have a extension cord and a Arduino usb to arduino plus cable with a adapter to outlet(I live in America so keep our outlets in mind and not the Europeans)

please don't use any big coding words when recommending fixes thank you
this is the code currently

#include <boarddefs.h>
#include <IRremote.h>
#include <IRremoteInt.h>
#include <ir_Lego_PF_BitStreamEncoder.h>
#include <Servo.h>

#define plus 0
#define minus 0
Servo myservo;
int val;
bool cwRotation, acwRotation;
const int receiver = 7;  // do you have pin 7 free for the receiver?
IRrecv irrecv(receiver);
decode_results results;

void setup() {

  Serial.begin(9600);
  IRrecv enableIRIn()

    myservo.attached(9);
}

void loop() {

  if (IRrecv decode(&results)) {

    Serial.println(results.value, HEX);
    if (results.value == plus) {
      cwRotation = !cwRotation;
      cwRotation = false;
    }

    if (results.value == minus) {
      acwRotation = !acwRotation;
      cwRotation = false;

      if (results.value == plus) {
        cwRotation = !cwRotation;
        cwRoataion = false;
      }
    }
  }

  if (cwRotation && (val != 180)) {

    val++;
  }
  if (acwRotation(val != 0)) {
    val--;
  }
  Servo.write(val);
  irrecv.resume();
  delay(20);
}

i

for your first bug it's because you have the underscore in the wrong place in

it should read

 decode_results results;

but that's no longer how you use that library.

➜ Look at the examples for IRremote. The API has evolved

There's all sorts of issues with this code

should be

myservo.attach(9);

since that's what you already named the object, and it's just attach, not attached.
Standby, more to come...
edit:

I have no idea what this is.

what pin are you using? I think if you go with this definition, you need the .h file "PinDefinitionsAndMore" or you can do like:

 const int receiver = 7; // do you have pin 7 free for the receiver?
 IRrecv irrecv(receiver);

also, irrecv.resume();
should be almost the last thing in your void loop() I think, at least that's what I do so I moved it in your sketch to be like:

 servo.write(val);
 irrecv.resume();
 delay(20);

before the final curly brace in void loop()

All of this untested, still working through but have to go for rest of morning since I am still trying to figure out

 if (results.value== plus){
  cwRotation =!cwRoataion;
  cwRoataion = false;
  }

what you think this does. There's no comments or Serial.println("someUsefulFeedback");
or
Serial.println(someUsefulValue);
so with only two cups of joe in my veins this morning so far, I'll have to come back to this.
You'll at least want to keep your spelling of "cwRotation" consistent throughout its usage.

I am sorry about the code, I fully got the code from probably the worst tutorial on the planet I have absolutely no idea what any of this code does. also after putting in all the fixes from you guys it is giving me so many less errors I am very appreciative for all your guys help already.

how do you plan to succeed in your project then?

that was a exaggeration I have a idea of what the code does and I know what to copy and paste in order to get it to do what it want it to also have a basic idea of servos

Ok, So let's stop rearranging deck chairs on the Titanic and get down to what you want to accomplish, because you said:

but I'm afraid I have receipts, friend, see my initial response :wink: but that's ok. Without further ado, give this a read for the rest of the culture here on getting us to help you.
https://forum.arduino.cc/t/how-to-get-the-best-out-of-this-forum/681308

So after you've read that, and followed it's instructions in the way of providing all the necessary details listed therein, also provide a description of what your game is supposed to do, and don't forget to include all the parts as the link just ^ instructed, also including the IR remote brand you're trying you interface with Arduino. Sony? Panasonic? something else?

Ok, I just read the whole thing and its long I am going to go make some edits to my original posts. also I have two questions, what if you want to show everyone helping you how the code looks with all the fixes, how would that look and what would I change? the and the second question is do you have to fully post the errors because in my case this is how my error looks "C:\Users\"my student ID"\OneDrive - "the county my schools is in"\Documents\Arduino\shoot_game_code\shoot_game_code.ino: error and the probelm code" and with the information in the error it would be very easy you track me down in real life, which make me a little worried about posting all that online.

Yes, good concern to have. Certainly don't post identifying info.
Let's focus on the code you have, post the whole code using code tags in one block.
In the Arduino IDE, press CTRL+T to auto format the code. Then copy/paste it here.
Sometimes it doesn't want to cooperate in one block due to blank lines in the code, just delete the blank lines to make one uniform block inside one set of code tags.

For errors, going from

it looks like your sketchbook isn't in the preferred location (although you have errors in the code regardless of this, at least as of the last time you posted any code).

Double check in the IDE under

File > Preferences > Sketchbook location

that your sketchbook is actually in the same place that is listed there. If you get this sorted out, you can rule out the folder tree causing your woes and simply copy/paste only the error messages with NO identifying info here for us to look at.

Ideally, there should be a folder called "sketchbook" and your custom libraries are typically saved INSIDE the sketchbook in a folder that you make called "libraries".

for me, it's:
C:\Users\Hallowed31\Documents\Arduino\sketchbook
and the IRRemote library is inside a subfolder like this:
C:\Users\Hallowed31\Documents\Arduino\sketchbook\libraries\IRRemote

what exactly should I change about the folder in order to fix it and do you have and recommendations of where I should put it

You follow the instructions.

  • List all components including part numbers (such as Arduino Uno, TSOP38238, whatever you actually have)
  • post your entire code using code tags so that someone here can copy/paste it to their own IDE and take a look. If I compile your code on my IDE, the errors will contain my folder tree in the error messages, not yours, so no need to worry there.
  • If you can, a hand drawn schematic of your circuit including how you are powering things
  • a detailed, step by step description of how the game is supposed to work, for ex:
    "one player, with a Sony remote presses the ENTER button toward a target using TSOP38238 to detect the remote. (note, I happen to use these a lot but your IR receiver may be a different product than this) and the Arduino counts how fast they can shoot the target inside of ten seconds, incrementing the score by 100 point with each button press", something like that.

Ensure first that your sketches are saved where the IDE thinks they are saved, according to my instructions in post #9.

Or, try this:

Copy/paste this sketch into your IDE and save it as whatever you want to name it. Then upload it to your Arduino. Open the serial monitor, ensure it's set to 9600 baud and see if it works. If so, good start.

void setup() {
  Serial.begin(9600);
}
void loop() {
  Serial.println("Hello, World!");
  delay(1000);
}

Report back.

So now that you've either
a) checked that your IDE knows where to look for your sketchbook
or
b) successfully run the Hello World sketch I posted
then what I want you to do is upload an example sketch from the IRRemote
library you have. Ideally it will be one that prints out on the serial monitor any info at all about
the IR signal you give it. Of course, you will have to build the circuit which should just be four connections to your Arduino: +, - and signal pins on the IR receiver, and the USB cable from Arduino to your computer.

If it uploads without errors and ideally if you can test it out with some remote, great.
Then you can eliminate libraries and sketches being saved in the wrong locations, since obviously the Arduino knew where to find them.

If you can't do this, report back.

Also, if you have concerns about online safety (which you always should), have your teacher look over this forum thread to ensure that everything exchanged is approved according to the school's online safety rules/policy.

EDIT: see post #16 for the code with all the changes

Not quite. It should be

myservo.attach(9);

also this:

IRrecv enableIRIn()

needs a semi colon at the end, so

IRrecv enableIRIn();

is correct, which will take care of this error:

Also, you will get an error for

I would try:

if (irrecv.decode(&results)) {

You will also get an error near the end of loop() for this line

servo.write(val);

Remember, you named your servo "myservo" so this needs to remain consistent. Use this instead:

myservo.write(val);

You will also get errors about cwRotation and acwRotation
'acwRotation' cannot be used as a function

so I rewrote it as nested conditionals as follows:

  if (cwRotation) {
    if (val != 180) {
      val++;
    }
  }
  if (acwRotation) {
    if (val != 0) {
      val--;
    }
  }

Maybe I missed this before. So you can upload an example sketch from that library without errors?

Ok, so got your code to compile.
Notes:
I did not roll back my libraries. Whereas you have

after digging up the lego one on Github and making a new tab in sketch named "ir_Lego_PF_BitStreamEncoder.h" (no quotes
AND making a third tab in sketch called
"PinDefinitionsAndMore.h" (again, no quotes in the naming of the tab)
and replacing your

#include <boarddefs.h>
#include <ir_Lego_PF_BitStreamEncoder.h>

with

#include "PinDefinitionsAndMore.h"
#include "ir_Lego_PF_BitStreamEncoder.h"

(note the quotation marks ARE there this time - it's so the IDE looks for new tabs in sketch rather than looking in the libraries folder)

AND ensuring that the PinDefinitionsAndMore.h tab contained this:

/*
 *  PinDefinitionsAndMore.h
 *
 *  Contains pin definitions for IRremote examples for various platforms
 *  as well as definitions for feedback LED and tone() and includes
 *
 *  Copyright (C) 2021-2022  Armin Joachimsmeyer
 *  armin.joachimsmeyer@gmail.com
 *
 *  This file is part of IRremote https://github.com/Arduino-IRremote/Arduino-IRremote.
 *
 *  Arduino-IRremote is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program. If not, see <http://www.gnu.org/licenses/gpl.html>.
 *
 */

/*
 * Pin mapping table for different platforms
 *
 * Platform     IR input    IR output   Tone      Core/Pin schema
 * --------------------------------------------------------------
 * DEFAULT/AVR  2           3           4
 * ATtinyX5     0|PB0       4|PB4       3|PB3
 * ATtiny167    3|PA3       2|PA2       7|PA7     ATTinyCore
 * ATtiny167    9|PA3       8|PA2       5|PA7     Digispark pro
 * ATtiny3217  18|PA1      19|PA2      20|PA3     MegaTinyCore
 * ATtiny1604   2           3|PA5       %
 * SAMD21       3           4           5
 * ESP8266      14|D5       12|D6       %
 * ESP32        15          4           27
 * BluePill     PA6         PA7         PA3
 * APOLLO3      11          12          5
 * RP2040       3|GPIO15    4|GPIO16    5|GPIO17
 */
//#define _IR_MEASURE_TIMING // For debugging purposes.

#if defined(__AVR__)
#if defined(__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__) // Digispark board
#include "ATtinySerialOut.hpp" // Available as Arduino library "ATtinySerialOut". saves 370 bytes program memory and 38 bytes RAM for digistump core
#define IR_RECEIVE_PIN  0
#define IR_SEND_PIN     4 // Pin 2 is serial output with ATtinySerialOut. Pin 1 is internal LED and Pin3 is USB+ with pullup on Digispark board.
#define TONE_PIN        3
#define _IR_TIMING_TEST_PIN 3

#  elif defined(__AVR_ATtiny87__) || defined(__AVR_ATtiny167__) // Digispark pro board
#include "ATtinySerialOut.hpp" // Available as Arduino library "ATtinySerialOut"
// For ATtiny167 Pins PB6 and PA3 are usable as interrupt source.
#  if defined(ARDUINO_AVR_DIGISPARKPRO)
#define IR_RECEIVE_PIN   9 // PA3 - on Digispark board labeled as pin 9
//#define IR_RECEIVE_PIN  14 // PB6 / INT0 is connected to USB+ on DigisparkPro boards
#define IR_SEND_PIN      8 // PA2 - on Digispark board labeled as pin 8
#define TONE_PIN         5 // PA7
#define _IR_TIMING_TEST_PIN 10 // PA4
#  else
#define IR_RECEIVE_PIN  3
#define IR_SEND_PIN     2
#define TONE_PIN        7
#  endif

#  elif defined(__AVR_ATtiny88__) // MH-ET Tiny88 board
#include "ATtinySerialOut.hpp" // Available as Arduino library "ATtinySerialOut". Saves 128 bytes program memory
// Pin 6 is TX pin 7 is RX
#define IR_RECEIVE_PIN   3 // INT1
#define IR_SEND_PIN      4
#define TONE_PIN         9
#define _IR_TIMING_TEST_PIN 8

#  elif defined(__AVR_ATtiny1616__)  || defined(__AVR_ATtiny3216__) || defined(__AVR_ATtiny3217__) // Tiny Core Dev board
#define IR_RECEIVE_PIN  18
#define IR_SEND_PIN     19
#define TONE_PIN        20
#define APPLICATION_PIN  0 // PA4
#undef LED_BUILTIN         // No LED available on the TinyCore 32 board, take the one on the programming board which is connected to the DAC output
#define LED_BUILTIN      2 // PA6

#  elif defined(__AVR_ATtiny1604__)
#define IR_RECEIVE_PIN   2 // To be compatible with interrupt example, pin 2 is chosen here.
#define IR_SEND_PIN      3
#define APPLICATION_PIN  5

#define tone(...) void()      // Define as void, since TCB0_INT_vect is also used by tone()
#define noTone(a) void()
#define TONE_PIN        42 // Dummy for examples using it

#  elif defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__) \
|| defined(__AVR_ATmega644__) || defined(__AVR_ATmega644P__) \
|| defined(__AVR_ATmega324P__) || defined(__AVR_ATmega324A__) \
|| defined(__AVR_ATmega324PA__) || defined(__AVR_ATmega164A__) \
|| defined(__AVR_ATmega164P__) || defined(__AVR_ATmega32__) \
|| defined(__AVR_ATmega16__) || defined(__AVR_ATmega8535__) \
|| defined(__AVR_ATmega64__) || defined(__AVR_ATmega128__) \
|| defined(__AVR_ATmega1281__) || defined(__AVR_ATmega2561__) \
|| defined(__AVR_ATmega8515__) || defined(__AVR_ATmega162__)
#define IR_RECEIVE_PIN      2
#define IR_SEND_PIN        13
#define TONE_PIN            4
#define APPLICATION_PIN     5
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
#define _IR_TIMING_TEST_PIN 7

#  else // Default as for ATmega328 like on Uno, Nano, Leonardo etc.
#define IR_RECEIVE_PIN      2 // To be compatible with interrupt example, pin 2 is chosen here.
#define IR_SEND_PIN         3
#define TONE_PIN            4
#define APPLICATION_PIN     5
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
#define _IR_TIMING_TEST_PIN 7

#    if defined(ARDUINO_AVR_PROMICRO) // Sparkfun Pro Micro is __AVR_ATmega32U4__ but has different external circuit
// We have no built in LED at pin 13 -> reuse RX LED
#undef LED_BUILTIN
#define LED_BUILTIN         LED_BUILTIN_RX
#    endif
#  endif // defined(__AVR_ATtiny25__)...

#elif defined(ESP8266)
#define FEEDBACK_LED_IS_ACTIVE_LOW // The LED on my board (D4) is active LOW
#define IR_RECEIVE_PIN          14 // D5
#define IR_SEND_PIN             12 // D6 - D4/pin 2 is internal LED
#define _IR_TIMING_TEST_PIN     13 // D7
#define APPLICATION_PIN          0 // D3

#define tone(...) void()      // tone() inhibits receive timer
#define noTone(a) void()
#define TONE_PIN                42 // Dummy for examples using it

#elif defined(ESP32)
#include <Arduino.h>

// tone() is included in ESP32 core since 2.0.2
#if !defined(ESP_ARDUINO_VERSION_VAL)
#define ESP_ARDUINO_VERSION_VAL(major, minor, patch) 12345678
#endif
#if ESP_ARDUINO_VERSION  <= ESP_ARDUINO_VERSION_VAL(2, 0, 2)
#define TONE_LEDC_CHANNEL        1  // Using channel 1 makes tone() independent of receiving timer -> No need to stop receiving timer.
void tone(uint8_t aPinNumber, unsigned int aFrequency){
    ledcAttachPin(aPinNumber, TONE_LEDC_CHANNEL);
    ledcWriteTone(TONE_LEDC_CHANNEL, aFrequency);
}
void tone(uint8_t aPinNumber, unsigned int aFrequency, unsigned long aDuration){
    ledcAttachPin(aPinNumber, TONE_LEDC_CHANNEL);
    ledcWriteTone(TONE_LEDC_CHANNEL, aFrequency);
    delay(aDuration);
    ledcWriteTone(TONE_LEDC_CHANNEL, 0);
}
void noTone(uint8_t aPinNumber){
    ledcWriteTone(TONE_LEDC_CHANNEL, 0);
}
#endif // ESP_ARDUINO_VERSION  <= ESP_ARDUINO_VERSION_VAL(2, 0, 2)

#define IR_RECEIVE_PIN          15  // D15
#define IR_SEND_PIN              4  // D4
#define TONE_PIN                27  // D27 25 & 26 are DAC0 and 1
#define APPLICATION_PIN         16  // RX2 pin

#elif defined(ARDUINO_ARCH_STM32) || defined(ARDUINO_ARCH_STM32F1) // BluePill
// Timer 3 blocks PA6, PA7, PB0, PB1 for use by Servo or tone()
#define IR_RECEIVE_PIN          PA6
#define IR_SEND_PIN             PA7
#define TONE_PIN                PA3
#define _IR_TIMING_TEST_PIN     PA5
#define APPLICATION_PIN         PA2
#  if defined(ARDUINO_GENERIC_STM32F103C) || defined(ARDUINO_BLUEPILL_F103C8)
// BluePill LED is active low
#define FEEDBACK_LED_IS_ACTIVE_LOW
#  endif

#elif defined(ARDUINO_ARCH_APOLLO3) // Sparkfun Apollo boards
#define IR_RECEIVE_PIN  11
#define IR_SEND_PIN     12
#define TONE_PIN         5

#elif defined(ARDUINO_ARCH_MBED) && defined(ARDUINO_ARCH_MBED_NANO) // Arduino Nano 33 BLE
#define IR_RECEIVE_PIN      3   // GPIO15 Start with pin 3 since pin 2|GPIO25 is connected to LED on Pi pico
#define IR_SEND_PIN         4   // GPIO16
#define TONE_PIN            5
#define APPLICATION_PIN     6
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 7 // E.g. used for examples which use LED_BUILDIN for example output.
#define _IR_TIMING_TEST_PIN 8

#elif defined(ARDUINO_ARCH_RP2040) // Arduino Nano Connect, Pi Pico with arduino-pico core https://github.com/earlephilhower/arduino-pico
#define IR_RECEIVE_PIN      15  // to be compatible with the Arduino Nano RP2040 Connect (pin3)
#define IR_SEND_PIN         16
#define TONE_PIN            17
#define APPLICATION_PIN     18
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 19 // E.g. used for examples which use LED_BUILDIN for example output.
#define _IR_TIMING_TEST_PIN 20

// If you program the Nano RP2040 Connect with this core, then you must redefine LED_BUILTIN
// and use the external reset with 1 kOhm to ground to enter UF2 mode
#undef LED_BUILTIN
#define LED_BUILTIN          6

#elif defined(PARTICLE) // !!!UNTESTED!!!
#define IR_RECEIVE_PIN      A4
#define IR_SEND_PIN         A5 // Particle supports multiple pins

#define LED_BUILTIN         D7

/*
 * 4 times the same (default) layout for easy adaption in the future
 */
#elif defined(TEENSYDUINO) // Teensy 2.0 is handled at default for ATmega328 like on Uno, Nano, Leonardo etc.
#define IR_RECEIVE_PIN      2
#define IR_SEND_PIN         3
#define TONE_PIN            4
#define APPLICATION_PIN     5
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
#define _IR_TIMING_TEST_PIN 7

#elif defined(ARDUINO_ARCH_MBED) // Arduino Nano 33 BLE
#define IR_RECEIVE_PIN      2
#define IR_SEND_PIN         3
#define TONE_PIN            4
#define APPLICATION_PIN     5
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
#define _IR_TIMING_TEST_PIN 7

#elif defined(ARDUINO_ARCH_SAMD) || defined(ARDUINO_ARCH_SAM)
#define IR_RECEIVE_PIN      2
#define IR_SEND_PIN         3
#define TONE_PIN            4
#define APPLICATION_PIN     5
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
#define _IR_TIMING_TEST_PIN 7

#if !defined(ARDUINO_SAMD_ADAFRUIT)
// On the Zero and others we switch explicitly to SerialUSB
#define Serial SerialUSB
#endif

// Definitions for the Chinese SAMD21 M0-Mini clone, which has no led connected to D13/PA17.
// Attention!!! D2 and D4 are swapped on these boards!!!
// If you connect the LED, it is on pin 24/PB11. In this case activate the next two lines.
//#undef LED_BUILTIN
//#define LED_BUILTIN 24 // PB11
// As an alternative you can choose pin 25, it is the RX-LED pin (PB03), but active low.In this case activate the next 3 lines.
//#undef LED_BUILTIN
//#define LED_BUILTIN 25 // PB03
//#define FEEDBACK_LED_IS_ACTIVE_LOW // The RX LED on the M0-Mini is active LOW

#elif defined (NRF51) // BBC micro:bit
#define IR_RECEIVE_PIN      2
#define IR_SEND_PIN         3
#define APPLICATION_PIN     1
#define _IR_TIMING_TEST_PIN 4

#define tone(...) void()    // no tone() available
#define noTone(a) void()
#define TONE_PIN           42 // Dummy for examples using it

#else
#warning Board / CPU is not detected using pre-processor symbols -> using default values, which may not fit. Please extend PinDefinitionsAndMore.h.
// Default valued for unidentified boards
#define IR_RECEIVE_PIN      2
#define IR_SEND_PIN         3
#define TONE_PIN            4
#define APPLICATION_PIN     5
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
#define _IR_TIMING_TEST_PIN 7
#endif // defined(ESP8266)

#if defined(ESP32) || defined(ARDUINO_ARCH_RP2040) || defined(PARTICLE) || defined(ARDUINO_ARCH_MBED)
#define SEND_PWM_BY_TIMER // We do not have pin restrictions for this CPU's, so lets use the hardware PWM for send carrier signal generation
#else
# if defined(SEND_PWM_BY_TIMER)
#undef IR_SEND_PIN // SendPin is determined by timer! This avoids warning in IRTimer.hpp
#  endif
#endif

#if !defined (FLASHEND)
#define FLASHEND 0xFFFF // Dummy value for platforms where FLASHEND is not defined
#endif
/*
 * Helper macro for getting a macro definition as string
 */
#if !defined(STR_HELPER)
#define STR_HELPER(x) #x
#define STR(x) STR_HELPER(x)
#endif

FINALLY I was able to get your code to compile. That does not mean it works, I didn't test it and don't have the materials for the rest of your circuit.

NOTE that I am using library IRRemote by shirriff, z3to, ArminJo version 3.8.0

FULL SKETCH, compiles for me on Arduino version 1.8.10:
(tab one, main sketch tab):

#include "PinDefinitionsAndMore.h"
#include <IRremote.h>
#include <IRremoteInt.h>
#include "ir_Lego_PF_BitStreamEncoder.h"
#include <Servo.h>

#define plus 0
#define minus 0
Servo myservo;
int val;
bool cwRotation, acwRotation;
const int receiver = 7; // do you have pin 7 free for the receiver?
IRrecv irrecv(receiver);
decode_results results;

void setup() {
  Serial.begin(9600);
  IRrecv enableIRIn();
  myservo.attach(9);
}

void loop() {
  if (irrecv.decode(&results)) {
    Serial.println(results.value, HEX);
    if (results.value == plus) {
      cwRotation = !cwRotation;
      cwRotation = false;
    }
    if (results.value == minus) {
      acwRotation = !acwRotation;
      cwRotation = false;
    }
  }
  if (cwRotation) {
    if (val != 180) {
      val++;
    }
  }
  if (acwRotation) {
    if (val != 0) {
      val--;
    }
  }

  myservo.write(val);
  irrecv.resume();
  delay(20);
}

tab 2: PinDefinitionsAndMore.h:

/*
 *  PinDefinitionsAndMore.h
 *
 *  Contains pin definitions for IRremote examples for various platforms
 *  as well as definitions for feedback LED and tone() and includes
 *
 *  Copyright (C) 2021-2022  Armin Joachimsmeyer
 *  armin.joachimsmeyer@gmail.com
 *
 *  This file is part of IRremote https://github.com/Arduino-IRremote/Arduino-IRremote.
 *
 *  Arduino-IRremote is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program. If not, see <http://www.gnu.org/licenses/gpl.html>.
 *
 */

/*
 * Pin mapping table for different platforms
 *
 * Platform     IR input    IR output   Tone      Core/Pin schema
 * --------------------------------------------------------------
 * DEFAULT/AVR  2           3           4
 * ATtinyX5     0|PB0       4|PB4       3|PB3
 * ATtiny167    3|PA3       2|PA2       7|PA7     ATTinyCore
 * ATtiny167    9|PA3       8|PA2       5|PA7     Digispark pro
 * ATtiny3217  18|PA1      19|PA2      20|PA3     MegaTinyCore
 * ATtiny1604   2           3|PA5       %
 * SAMD21       3           4           5
 * ESP8266      14|D5       12|D6       %
 * ESP32        15          4           27
 * BluePill     PA6         PA7         PA3
 * APOLLO3      11          12          5
 * RP2040       3|GPIO15    4|GPIO16    5|GPIO17
 */
//#define _IR_MEASURE_TIMING // For debugging purposes.

#if defined(__AVR__)
#if defined(__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__) // Digispark board
#include "ATtinySerialOut.hpp" // Available as Arduino library "ATtinySerialOut". saves 370 bytes program memory and 38 bytes RAM for digistump core
#define IR_RECEIVE_PIN  0
#define IR_SEND_PIN     4 // Pin 2 is serial output with ATtinySerialOut. Pin 1 is internal LED and Pin3 is USB+ with pullup on Digispark board.
#define TONE_PIN        3
#define _IR_TIMING_TEST_PIN 3

#  elif defined(__AVR_ATtiny87__) || defined(__AVR_ATtiny167__) // Digispark pro board
#include "ATtinySerialOut.hpp" // Available as Arduino library "ATtinySerialOut"
// For ATtiny167 Pins PB6 and PA3 are usable as interrupt source.
#  if defined(ARDUINO_AVR_DIGISPARKPRO)
#define IR_RECEIVE_PIN   9 // PA3 - on Digispark board labeled as pin 9
//#define IR_RECEIVE_PIN  14 // PB6 / INT0 is connected to USB+ on DigisparkPro boards
#define IR_SEND_PIN      8 // PA2 - on Digispark board labeled as pin 8
#define TONE_PIN         5 // PA7
#define _IR_TIMING_TEST_PIN 10 // PA4
#  else
#define IR_RECEIVE_PIN  3
#define IR_SEND_PIN     2
#define TONE_PIN        7
#  endif

#  elif defined(__AVR_ATtiny88__) // MH-ET Tiny88 board
#include "ATtinySerialOut.hpp" // Available as Arduino library "ATtinySerialOut". Saves 128 bytes program memory
// Pin 6 is TX pin 7 is RX
#define IR_RECEIVE_PIN   3 // INT1
#define IR_SEND_PIN      4
#define TONE_PIN         9
#define _IR_TIMING_TEST_PIN 8

#  elif defined(__AVR_ATtiny1616__)  || defined(__AVR_ATtiny3216__) || defined(__AVR_ATtiny3217__) // Tiny Core Dev board
#define IR_RECEIVE_PIN  18
#define IR_SEND_PIN     19
#define TONE_PIN        20
#define APPLICATION_PIN  0 // PA4
#undef LED_BUILTIN         // No LED available on the TinyCore 32 board, take the one on the programming board which is connected to the DAC output
#define LED_BUILTIN      2 // PA6

#  elif defined(__AVR_ATtiny1604__)
#define IR_RECEIVE_PIN   2 // To be compatible with interrupt example, pin 2 is chosen here.
#define IR_SEND_PIN      3
#define APPLICATION_PIN  5

#define tone(...) void()      // Define as void, since TCB0_INT_vect is also used by tone()
#define noTone(a) void()
#define TONE_PIN        42 // Dummy for examples using it

#  elif defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__) \
|| defined(__AVR_ATmega644__) || defined(__AVR_ATmega644P__) \
|| defined(__AVR_ATmega324P__) || defined(__AVR_ATmega324A__) \
|| defined(__AVR_ATmega324PA__) || defined(__AVR_ATmega164A__) \
|| defined(__AVR_ATmega164P__) || defined(__AVR_ATmega32__) \
|| defined(__AVR_ATmega16__) || defined(__AVR_ATmega8535__) \
|| defined(__AVR_ATmega64__) || defined(__AVR_ATmega128__) \
|| defined(__AVR_ATmega1281__) || defined(__AVR_ATmega2561__) \
|| defined(__AVR_ATmega8515__) || defined(__AVR_ATmega162__)
#define IR_RECEIVE_PIN      2
#define IR_SEND_PIN        13
#define TONE_PIN            4
#define APPLICATION_PIN     5
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
#define _IR_TIMING_TEST_PIN 7

#  else // Default as for ATmega328 like on Uno, Nano, Leonardo etc.
#define IR_RECEIVE_PIN      2 // To be compatible with interrupt example, pin 2 is chosen here.
#define IR_SEND_PIN         3
#define TONE_PIN            4
#define APPLICATION_PIN     5
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
#define _IR_TIMING_TEST_PIN 7

#    if defined(ARDUINO_AVR_PROMICRO) // Sparkfun Pro Micro is __AVR_ATmega32U4__ but has different external circuit
// We have no built in LED at pin 13 -> reuse RX LED
#undef LED_BUILTIN
#define LED_BUILTIN         LED_BUILTIN_RX
#    endif
#  endif // defined(__AVR_ATtiny25__)...

#elif defined(ESP8266)
#define FEEDBACK_LED_IS_ACTIVE_LOW // The LED on my board (D4) is active LOW
#define IR_RECEIVE_PIN          14 // D5
#define IR_SEND_PIN             12 // D6 - D4/pin 2 is internal LED
#define _IR_TIMING_TEST_PIN     13 // D7
#define APPLICATION_PIN          0 // D3

#define tone(...) void()      // tone() inhibits receive timer
#define noTone(a) void()
#define TONE_PIN                42 // Dummy for examples using it

#elif defined(ESP32)
#include <Arduino.h>

// tone() is included in ESP32 core since 2.0.2
#if !defined(ESP_ARDUINO_VERSION_VAL)
#define ESP_ARDUINO_VERSION_VAL(major, minor, patch) 12345678
#endif
#if ESP_ARDUINO_VERSION  <= ESP_ARDUINO_VERSION_VAL(2, 0, 2)
#define TONE_LEDC_CHANNEL        1  // Using channel 1 makes tone() independent of receiving timer -> No need to stop receiving timer.
void tone(uint8_t aPinNumber, unsigned int aFrequency){
    ledcAttachPin(aPinNumber, TONE_LEDC_CHANNEL);
    ledcWriteTone(TONE_LEDC_CHANNEL, aFrequency);
}
void tone(uint8_t aPinNumber, unsigned int aFrequency, unsigned long aDuration){
    ledcAttachPin(aPinNumber, TONE_LEDC_CHANNEL);
    ledcWriteTone(TONE_LEDC_CHANNEL, aFrequency);
    delay(aDuration);
    ledcWriteTone(TONE_LEDC_CHANNEL, 0);
}
void noTone(uint8_t aPinNumber){
    ledcWriteTone(TONE_LEDC_CHANNEL, 0);
}
#endif // ESP_ARDUINO_VERSION  <= ESP_ARDUINO_VERSION_VAL(2, 0, 2)

#define IR_RECEIVE_PIN          15  // D15
#define IR_SEND_PIN              4  // D4
#define TONE_PIN                27  // D27 25 & 26 are DAC0 and 1
#define APPLICATION_PIN         16  // RX2 pin

#elif defined(ARDUINO_ARCH_STM32) || defined(ARDUINO_ARCH_STM32F1) // BluePill
// Timer 3 blocks PA6, PA7, PB0, PB1 for use by Servo or tone()
#define IR_RECEIVE_PIN          PA6
#define IR_SEND_PIN             PA7
#define TONE_PIN                PA3
#define _IR_TIMING_TEST_PIN     PA5
#define APPLICATION_PIN         PA2
#  if defined(ARDUINO_GENERIC_STM32F103C) || defined(ARDUINO_BLUEPILL_F103C8)
// BluePill LED is active low
#define FEEDBACK_LED_IS_ACTIVE_LOW
#  endif

#elif defined(ARDUINO_ARCH_APOLLO3) // Sparkfun Apollo boards
#define IR_RECEIVE_PIN  11
#define IR_SEND_PIN     12
#define TONE_PIN         5

#elif defined(ARDUINO_ARCH_MBED) && defined(ARDUINO_ARCH_MBED_NANO) // Arduino Nano 33 BLE
#define IR_RECEIVE_PIN      3   // GPIO15 Start with pin 3 since pin 2|GPIO25 is connected to LED on Pi pico
#define IR_SEND_PIN         4   // GPIO16
#define TONE_PIN            5
#define APPLICATION_PIN     6
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 7 // E.g. used for examples which use LED_BUILDIN for example output.
#define _IR_TIMING_TEST_PIN 8

#elif defined(ARDUINO_ARCH_RP2040) // Arduino Nano Connect, Pi Pico with arduino-pico core https://github.com/earlephilhower/arduino-pico
#define IR_RECEIVE_PIN      15  // to be compatible with the Arduino Nano RP2040 Connect (pin3)
#define IR_SEND_PIN         16
#define TONE_PIN            17
#define APPLICATION_PIN     18
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 19 // E.g. used for examples which use LED_BUILDIN for example output.
#define _IR_TIMING_TEST_PIN 20

// If you program the Nano RP2040 Connect with this core, then you must redefine LED_BUILTIN
// and use the external reset with 1 kOhm to ground to enter UF2 mode
#undef LED_BUILTIN
#define LED_BUILTIN          6

#elif defined(PARTICLE) // !!!UNTESTED!!!
#define IR_RECEIVE_PIN      A4
#define IR_SEND_PIN         A5 // Particle supports multiple pins

#define LED_BUILTIN         D7

/*
 * 4 times the same (default) layout for easy adaption in the future
 */
#elif defined(TEENSYDUINO) // Teensy 2.0 is handled at default for ATmega328 like on Uno, Nano, Leonardo etc.
#define IR_RECEIVE_PIN      2
#define IR_SEND_PIN         3
#define TONE_PIN            4
#define APPLICATION_PIN     5
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
#define _IR_TIMING_TEST_PIN 7

#elif defined(ARDUINO_ARCH_MBED) // Arduino Nano 33 BLE
#define IR_RECEIVE_PIN      2
#define IR_SEND_PIN         3
#define TONE_PIN            4
#define APPLICATION_PIN     5
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
#define _IR_TIMING_TEST_PIN 7

#elif defined(ARDUINO_ARCH_SAMD) || defined(ARDUINO_ARCH_SAM)
#define IR_RECEIVE_PIN      2
#define IR_SEND_PIN         3
#define TONE_PIN            4
#define APPLICATION_PIN     5
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
#define _IR_TIMING_TEST_PIN 7

#if !defined(ARDUINO_SAMD_ADAFRUIT)
// On the Zero and others we switch explicitly to SerialUSB
#define Serial SerialUSB
#endif

// Definitions for the Chinese SAMD21 M0-Mini clone, which has no led connected to D13/PA17.
// Attention!!! D2 and D4 are swapped on these boards!!!
// If you connect the LED, it is on pin 24/PB11. In this case activate the next two lines.
//#undef LED_BUILTIN
//#define LED_BUILTIN 24 // PB11
// As an alternative you can choose pin 25, it is the RX-LED pin (PB03), but active low.In this case activate the next 3 lines.
//#undef LED_BUILTIN
//#define LED_BUILTIN 25 // PB03
//#define FEEDBACK_LED_IS_ACTIVE_LOW // The RX LED on the M0-Mini is active LOW

#elif defined (NRF51) // BBC micro:bit
#define IR_RECEIVE_PIN      2
#define IR_SEND_PIN         3
#define APPLICATION_PIN     1
#define _IR_TIMING_TEST_PIN 4

#define tone(...) void()    // no tone() available
#define noTone(a) void()
#define TONE_PIN           42 // Dummy for examples using it

#else
#warning Board / CPU is not detected using pre-processor symbols -> using default values, which may not fit. Please extend PinDefinitionsAndMore.h.
// Default valued for unidentified boards
#define IR_RECEIVE_PIN      2
#define IR_SEND_PIN         3
#define TONE_PIN            4
#define APPLICATION_PIN     5
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
#define _IR_TIMING_TEST_PIN 7
#endif // defined(ESP8266)

#if defined(ESP32) || defined(ARDUINO_ARCH_RP2040) || defined(PARTICLE) || defined(ARDUINO_ARCH_MBED)
#define SEND_PWM_BY_TIMER // We do not have pin restrictions for this CPU's, so lets use the hardware PWM for send carrier signal generation
#else
# if defined(SEND_PWM_BY_TIMER)
#undef IR_SEND_PIN // SendPin is determined by timer! This avoids warning in IRTimer.hpp
#  endif
#endif

#if !defined (FLASHEND)
#define FLASHEND 0xFFFF // Dummy value for platforms where FLASHEND is not defined
#endif
/*
 * Helper macro for getting a macro definition as string
 */
#if !defined(STR_HELPER)
#define STR_HELPER(x) #x
#define STR(x) STR_HELPER(x)
#endif

tab 3: ir_Lego_PF_BitStreamEncoder.h

class LegoPfBitStreamEncoder {
 private:
  uint16_t data;
  bool repeatMessage;
  int messageBitIdx;
  int repeatCount;
  int messageLength;

  // HIGH data bit = IR mark + high pause
  // LOW data bit = IR mark + low pause
  static const int LOW_BIT_DURATION = 421;
  static const int HIGH_BIT_DURATION = 711;
  static const int START_BIT_DURATION = 1184;
  static const int STOP_BIT_DURATION = 1184;
  static const int IR_MARK_DURATION = 158;
  static const int HIGH_PAUSE_DURATION = HIGH_BIT_DURATION - IR_MARK_DURATION;
  static const int LOW_PAUSE_DURATION = LOW_BIT_DURATION - IR_MARK_DURATION;
  static const int START_PAUSE_DURATION = START_BIT_DURATION - IR_MARK_DURATION;
  static const int STOP_PAUSE_DURATION = STOP_BIT_DURATION - IR_MARK_DURATION;
  static const int MESSAGE_BITS = 18;
  static const int MAX_MESSAGE_LENGTH = 16000;

 public:
  void reset(uint16_t data, bool repeatMessage) {
    this->data = data;
    this->repeatMessage = repeatMessage;
    messageBitIdx = 0;
    repeatCount = 0;
    messageLength = getMessageLength();
  }

  int getChannelId() const { return 1 + ((data >> 12) & 0x3); }

  int getMessageLength() const {
    // Sum up all marks
    int length = MESSAGE_BITS * IR_MARK_DURATION;

    // Sum up all pauses
    length += START_PAUSE_DURATION;
    for (unsigned long mask = 1UL << 15; mask; mask >>= 1) {
      if (data & mask) {
        length += HIGH_PAUSE_DURATION;
      } else {
        length += LOW_PAUSE_DURATION;
      }
    }
    length += STOP_PAUSE_DURATION;
    return length;
  }

  boolean next() {
    messageBitIdx++;
    if (messageBitIdx >= MESSAGE_BITS) {
      repeatCount++;
      messageBitIdx = 0;
    }
    if (repeatCount >= 1 && !repeatMessage) {
      return false;
    } else if (repeatCount >= 5) {
      return false;
    } else {
      return true;
    }
  }

  int getMarkDuration() const { return IR_MARK_DURATION; }

  int getPauseDuration() const {
    if (messageBitIdx == 0)
      return START_PAUSE_DURATION;
    else if (messageBitIdx < MESSAGE_BITS - 1) {
      return getDataBitPause();
    } else {
      return getStopPause();
    }
  }

 private:
  int getDataBitPause() const {
    const int pos = MESSAGE_BITS - 2 - messageBitIdx;
    const bool isHigh = data & (1 << pos);
    return isHigh ? HIGH_PAUSE_DURATION : LOW_PAUSE_DURATION;
  }

  int getStopPause() const {
    if (repeatMessage) {
      return getRepeatStopPause();
    } else {
      return STOP_PAUSE_DURATION;
    }
  }

  int getRepeatStopPause() const {
    if (repeatCount == 0 || repeatCount == 1) {
      return STOP_PAUSE_DURATION + 5 * MAX_MESSAGE_LENGTH - messageLength;
    } else if (repeatCount == 2 || repeatCount == 3) {
      return STOP_PAUSE_DURATION
             + (6 + 2 * getChannelId()) * MAX_MESSAGE_LENGTH - messageLength;
    } else {
      return STOP_PAUSE_DURATION;
    }
  }
};

END

Woah, Sorry I have radio silent these past couple days, I was overhauling the original post with all of the feedback. I will now go and try all of the recommendations you made. I won't have access to all the materials until next class but I can at least still see if it gives me the errors.

The actual functions(I think that's what you call the different types of words you use) that the library allows you to use I think changed from one version to the next so by using a different version it stopped giving me the error for this code
when using the IRremote library with the 2.2.3 version is stopped giving me errors for
either this line of code

IRrecv irrecv(receiver);

or this line of code

 decode_results results;

I can't remember.

Ok, I also got it to compile (when I hit verify no errors came up) on Arduino IDE 2.0.4, I am now going to try it.

Edit: it doesn't work. but the IR sensor picks up on the signal and I saw the servo move one time( literally only one time, it was when I booted it up) but and when I look at serial monitor nothing comes up and I Have already troubleshooted most of it, I replaced the Arduino uno, the IR sensor, the servo and the remote(individually) but still it doesn't move when I press the buttons(I have tried all the buttons on the remote).

It's your code. I just said it would compile, you'll have to learn how to pass the variable that is returned when the sensor is read into something you can use.