Hello , i have code below that is supposed to take the inpuit of a button and i am able to program this button to do something like lock my desktop, but my code isnt compiling. Here is my code-
#include <Keyboard.h>
#define KEY_PIN 2
static void KeyDown(void)
{
Keyboard.press(KEY_LEFT_GUI);
Keyboard.press(‘l’);
}
void setup(void)
{
Keyboard.begin();
pinMode(KEY_PIN, INPUT);
digitalWrite(KEY_PIN, HIGH);
}
void loop(void)
{
static uint8_t buttonStateLast = 0;
uint8_t buttonState;
buttonState = digitalRead(KEY_PIN);
if (buttonState != buttonStateLast) {
buttonStateLast = buttonState;
if (buttonState == 0) {
KeyDown();
delay(100);
Keyboard.releaseAll();
}
}
delay(50);
}
and here is my error code
Arduino: 1.8.12 (Windows Store 1.8.33.0) (Windows 10), Board: "Arduino Leonardo"
HID_hotkey_windows:15:18: error: stray '\342' in program
Keyboard.press(‘l’);
^
HID_hotkey_windows:15:19: error: stray '\200' in program
Keyboard.press(‘l’);
^
HID_hotkey_windows:15:20: error: stray '\230' in program
Keyboard.press(‘l’);
^
HID_hotkey_windows:15:22: error: stray '\342' in program
Keyboard.press(‘l’);
^
HID_hotkey_windows:15:23: error: stray '\200' in program
Keyboard.press(‘l’);
^
HID_hotkey_windows:15:24: error: stray '\231' in program
Keyboard.press(‘l’);
^
C:\Users\tjone\OneDrive\Desktop\Arduino\Arduino uno code\HID_hotkey_windows\HID_hotkey_windows.ino: In function 'void KeyDown()':
HID_hotkey_windows:15:21: error: 'l' was not declared in this scope
Keyboard.press(‘l’);
^
exit status 1
stray '\342' in program
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.