I'm trying to use a nano to create a keystroke when PIR sensor is tripped to turn my monitor on. I've searched and looked and read and have been at it 3 days but cannot seem to get it figured out. Here is the sketch I'm trying to use but I keep getting errors so I can't upload it.
Any help would be great appreciated!! I apologize in advance if I don't post this correctly formatted.
#include <Keyboard.h>
int sensorPin = 10;
void setup()
{
pinMode(sensorPin, INPUT);
Serial.begin(9600);
}
void sendWakeUp(void);
void loop()
{
if (digitalRead(sensorPin) == 1)
{
sendWakeUp();
while (digitalRead(sensorPin) == 1)
{
delay(1000);
}
}
delay(1000);
}
void sendWakeUp(void)
{
USBDevice.wakeupHost();
Keyboard.press(KEY_LEFT_CTRL);
delay(1);
Keyboard.release(KEY_LEFT_CTRL);
}
These are the errors I'm getting. Trying to fix them but have had no luck.
Arduino: 1.8.13 (Windows 10), Board: "Arduino Nano, ATmega328P"
In file included from C:\Users\cowbo\Downloads\F7MIIU0IL4FPFYR\F7MIIU0IL4FPFYR.ino:1:0:
C:\Program Files (x86)\Arduino\libraries\Keyboard\src/Keyboard.h:29:2: warning: #warning "Using legacy HID core (non pluggable)" [-Wcpp]
#warning "Using legacy HID core (non pluggable)"
^~~~~~~
C:\Users\cowbo\Downloads\F7MIIU0IL4FPFYR\F7MIIU0IL4FPFYR.ino: In function 'void sendWakeUp()':
F7MIIU0IL4FPFYR:24:3: error: 'USBDevice' was not declared in this scope
USBDevice.wakeupHost();
^~~~~~~~~
F7MIIU0IL4FPFYR:25:3: error: 'Keyboard' not found. Does your sketch include the line '#include <Keyboard.h>'?
Keyboard.press(KEY_LEFT_CTRL);
^~~~~~~~
F7MIIU0IL4FPFYR:25:18: error: 'KEY_LEFT_CTRL' was not declared in this scope
Keyboard.press(KEY_LEFT_CTRL);
^~~~~~~~~~~~~
exit status 1
'USBDevice' was not declared in this scope