i need help with my Projekt i wanna program a Keyboard. I have downloaded the "HID Buttons", to have a keyboard libary. But i dont know the problem with the Code now.
C:\Users\steni\Desktop\Tastatur_Eingabe\neu\neu.ino: In function 'void loop()':
C:\Users\steni\Desktop\Tastatur_Eingabe\neu\neu.ino:22:5: error: 'Keyboard' was not declared in this scope
Keyboard.write('1')
^~~~~~~~
C:\Users\steni\Desktop\Tastatur_Eingabe\neu\neu.ino:22:5: note: suggested alternative:
In file included from C:\Users\steni\Desktop\Tastatur_Eingabe\neu\neu.ino:1:0:
C:\Users\steni\Documents\Arduino\libraries\BlueFairy\src/Keyboard.h:73:15: note: 'ciag::bluefairy::Keyboard'
class Keyboard {
^~~~~~~~
Mehrere Bibliotheken wurden für "Keyboard.h" gefunden
Benutzt: C:\Users\steni\Documents\Arduino\libraries\BlueFairy
Nicht benutzt: C:\Users\steni\AppData\Local\Arduino15\libraries\Keyboard
exit status 1
Compilation error: 'Keyboard' not found. Does your sketch include the line '#include <Keyboard.h>'?
Which board are you compiling for? The Keyboard library is only usable on boards with native USB; so this excludes boards like Uno, Nano, Pro Mini and Mega.
That won't work. It should be pinMode(pin1, INPUT_PULLUP);
and don't forget that the logic will now be reversed, so pressing a button will be LOW and will read HIGH by default.
also, don't forget to end the command with ;
Lastly, with those fixes, and removing #include <HID_Buttons.h> altogether (is it necessary if you already have the Keyboard library?), and following the wisdom of @kmin
and @sterretje (compiling for an appropriate Arduino - I selected Leonardo), the fixed code does indeed compile, That's not to say it will work as you intend, but it compiles. Here's the full fix:
Also, did you know your sketch spends almost all of its time in delay(500);? That's blocking code; nothing can happen while those delay calls are being executed.
Not sure why you want a blinking light that has nothing to do with pressing some button and sending a char '1' but I thought I'd mention it since you will miss button presses and you won't be sending anything during that blinking LED routine.
Try using millis() instead.
Oh, neat. That will be a handy feature. Are there any you're aware of that I can try it on currently?
Nevermind, it shows in blue if I select Teensy LC, surely others are the same.
Thanks, good to know when I select a board for a future project (if you can pry the Nano Every from my cold, dead hands! )
EDIT: just actually scrolled through the Boards list in IDE version 1.8.10 (if it ain't broke, you're not fixing it hard enough) and holy moly there are a lot of boards.
How do folks keep up? I feel like a dinosaur.