'Keyboard' not found. Does your sketch include the line '#include <Keyboard.h>'?

Arduino: 1.8.13 (Windows 10), Board: "Arduino Uno"





















C:\Users\CheezWhizz114\Documents\Arduino Project\Receiver__RX_\Receiver__RX_.ino: In function 'void setup()':

Receiver__RX_:19:3: error: 'Keyboard' not found. Does your sketch include the line '#include <Keyboard.h>'?

   Keyboard.begin();

   ^~~~~~~~

C:\Users\druid\Documents\Arduino Project\Receiver__RX_\Receiver__RX_.ino: In function 'void loop()':

Receiver__RX_:35:15: error: 'Keyboard' not found. Does your sketch include the line '#include <Keyboard.h>'?

               Keyboard.press(KEY_LEFT_GUI);

               ^~~~~~~~

Receiver__RX_:35:30: error: 'KEY_LEFT_GUI' was not declared in this scope

               Keyboard.press(KEY_LEFT_GUI);

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

Receiver__RX_:36:30: error: 'KEY_RIGHT_CTRL' was not declared in this scope

               Keyboard.press(KEY_RIGHT_CTRL);

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

Receiver__RX_:54:30: error: 'KEY_F11' was not declared in this scope

               Keyboard.press(KEY_F11);

                              ^~~~~~~

Receiver__RX_:72:15: error: 'Keyboard' not found. Does your sketch include the line '#include <Keyboard.h>'?

               Keyboard.press(KEY_LEFT_GUI);

               ^~~~~~~~

Receiver__RX_:72:30: error: 'KEY_LEFT_GUI' was not declared in this scope

               Keyboard.press(KEY_LEFT_GUI);

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

Receiver__RX_:100:24: error: 'KEY_LEFT_CTRL' was not declared in this scope

         Keyboard.press(KEY_LEFT_CTRL);

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

Receiver__RX_:101:24: error: 'KEY_RIGHT_ARROW' was not declared in this scope

         Keyboard.press(KEY_RIGHT_ARROW);

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

exit status 1

'Keyboard' not found. Does your sketch include the line '#include <Keyboard.h>'?



This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

this is the fault I received. I've checked multiple threads beforehand, but I have included the keyboard library outside void setup and void loop, I also have the keyboard library installed, so I don't know what went wrong here. Does someone have an idea? I tried finding custom libraries but after some more searching I thought it wasn't necessary.

The code itsself;

#include <Keyboard.h>
#include <SPI.h>
#include <RF24.h>
#include <nRF24L01.h>

RF24 radio(5, 3); // CE, CSN

const byte address[6] = "00001";

int os = 2; //osx = 1, windows = 2, linux = 3
int function = 4; //lock the computer = 1, minimize active window = 2 , show desktop = 3, custom script = 4

void setup() {
  Serial.begin(9600);
  radio.begin();
  radio.openReadingPipe(0, address);
  radio.setPALevel(RF24_PA_MIN);
  radio.startListening();
  Keyboard.begin();
}

void loop() {
  if (radio.available()) {
    int trigger;
    radio.read(&trigger, sizeof(trigger));

    if (trigger == 1)
    {
      switch (os)
      {
        case 1: //osx
          switch (function)
          {
            case 1://lock computer
              Keyboard.press(KEY_LEFT_GUI);
              Keyboard.press(KEY_RIGHT_CTRL);
              Keyboard.press('q');
              delay(100);
              Keyboard.releaseAll();
              Serial.println(trigger);
              while (1);


            case 2: //minimize active window
              Keyboard.press(KEY_LEFT_GUI);
              Keyboard.press('m');
              delay(100);
              Keyboard.releaseAll();
              Serial.println(trigger);
              while (1);


            case 3: //show desktop
              Keyboard.press(KEY_F11);
              Keyboard.press('m');
              delay(100);
              Keyboard.releaseAll();
              Serial.println(trigger);
              while (1);


            case 4: //custome script
              while (1);


          }

        case 2: //windows
          switch (function)
          {
            case 1: //lock
              Keyboard.press(KEY_LEFT_GUI);
              Keyboard.press('l');
              delay(100);
              Keyboard.releaseAll();
              Serial.println(trigger);
              while (1);


            case 2: //minimize active window
              Keyboard.press(KEY_LEFT_GUI);
              Keyboard.press('m');
              delay(100);
              Keyboard.releaseAll();
              Serial.println(trigger);
              while (1);


            case 3: // show desktop
              Keyboard.press(KEY_LEFT_GUI);
              Keyboard.press('d');
              delay(100);
              Keyboard.releaseAll();
              Serial.println(trigger);
              while (1);


            case 4: //custome script
        Keyboard.press(KEY_LEFT_GUI);
        Keyboard.press(KEY_LEFT_CTRL);
        Keyboard.press(KEY_RIGHT_ARROW);
        delay(50);
        Keyboard.releaseAll();
        Serial.println(trigger);
              while (1);


          }

        case 3: //linux
          switch (function)
          {
            case 1:
              while (1);


            case 2:
              while (1);


            case 3:
              while (1);


            case 4:
              while (1);


          }

        case 4: //custom
        
          while (1);

      }

    }
  }
}

The keyboard library does not work with a Uno

See Keyboard - Arduino Reference

Thank you, it was a complete fault on my side for not changing the board settings. Though your help just woke me up :grinning:

At least you posted the full error output, which many don't, thus allowing it to be seen that you were compiling for a Uno even if that was not the board you were using