Це відео не доступне.
Перепрошуємо.
Control your keyboard with Arduino! Automate simple tasks!
Вставка
- Опубліковано 4 лис 2021
- 🤩 FREE Arduino Crash Course 👇👇
bit.ly/get_Ard...
Want to learn more? Check out our courses!
bit.ly/3k8kI0u
We designed this circuit board for beginners!
Kit-On-A-Shield: amzn.to/3lfWClU
**Get your Free Trial of Altium PCB design Software**
www.altium.com...
SHOP OUR FAVORITE STUFF! (affiliate links)
---------------------------------------------------
Get your Free Trial of Altium PCB design Software
www.altium.com...
We use Rev Captions for our subtitles
bit.ly/39trLeB
Arduino UNO R3:
Amazon: amzn.to/37eP4ra
Newegg: bit.ly/3fahas8
Budget Arduino Kits:
Amazon:amzn.to/3C0VqsH
Newegg:bit.ly/3j4tISX
Multimeter Options:
Amazon: amzn.to/3rRo3E0
Newegg: bit.ly/3rJoekA
Helping Hands:
Amazon: amzn.to/3C8IYXZ
Newegg: bit.ly/3fb03X1
Soldering Stations:
Amazon: amzn.to/2VawmP4
Newegg: bit.ly/3BZ6oio
AFFILIATES & REFERRALS
---------------------------------------------------
►Audible Plus Free trial: amzn.to/3j5IGrV
►Get LastPass: lastpass.wo8g....
►Join Honey- Save Money bit.ly/3xmj7rH
►Download Glasswire for Free:bit.ly/3iv1fql
FOLLOW US ELSEWHERE
---------------------------------------------------
Facebook: / programmingelectronics...
Twitter: / progelecacademy
Website: www.programmin...
**About Us:**
This Arduino lesson was created by Programming Electronics Academy. We are an online education company who seeks to help people learn about electronics and programming through the ubiquitous Arduino development board.
**We have no affiliation whatsoever with Arduino LLC, other than we think they are cool.**
I got the perfect use for this. Because I have arthritis, playing games on my computer can be difficult and I was thinking about building an input device where I can comfortably place my hand in its natural position and then operate buttons that would be mapped to the keyboard. I was initially planning to use the chip from an old keyboard and build an appropriate matrix, but I think this will be not only easier, but modifiable as well.
Thank you so much for this video. I've used an Arduino for many projects, but never played with these libraries.
Very cool application Roy - good luck on the build!
Great tutorial. Can I add if you find yourself in a keyboard/mouse runaway situation you can press and hold the reset button on your Arduino, the Arduino sketch won't run while the button is held in. Click load on your IDE and simultaneously release the reset button.
Thanks a ton for posting that Scott!
Can i use arduino nano or uno😢
A couple more small remarks:
1. @17:07 you say that Keyboard.write() prints ASCII. Actually, this is just a shortcut for press() followed by release(), so it can hit any key you want, like, e.g., Keyboard.write(KEY_PAGE_DOWN).
2. @19:19 you write
Keyboard.print("clear");
Keyboard.press(KEY_RETURN);
Keyboard.release(KEY_RETURN);
This can be simplified to
Keyboard.println("clear");
As println() is just print() followed by hitting the Return key.
Thanks for this!
MickeyMouse!!!!! hahahahahhahahahahhahahahah
2:40
Regarding begin() and end(): the purpose of these methods is to future-proof your sketch. If you use them as suggested by the documentation, your sketch should be compatible with future versions of the library. This means: never use another method before begin() nor after end(). Do not assume print() before begin() does nothing, and do not assume it does something either: don't make assumptions, just don't do it. And please, do not teach people to omit begin(). BTW, since version 1.0.4 of the library, begin() is not empty anymore.
Regarding your example program at the end of the video, you would be better off leaning how to use the “alias” command from bash. The Keyboard library is most useful when you want to build custom input devices, like a game controller or a barcode scanner. For regular task automation, software-only tools tend to be more effective.
Awesome - thanks for adding this Edgar!
Happy to see you still making videos. Quality content.
Thanks a ton!
Nice head's up on those library gotchas. Def good to know before diving in to a project
Thanks! I was struggling to figure out what was up when using those functions
@@programmingelectronics I def feel you. That was def an "ugh, relatable!!" part of the video. I've def felt that sting before :)
I use processing 3 for keyboard and mouse with ardino uno
I LOVE processing! That's what actually got me thinking about using Keyboard/mouse control. We have lessons on connecting to twitter through Arduino/Processing library called twitter4j -but we're using the Processing 4 I think?
Great tutorial! I love it
Thanks so much! It’s a fun library to work with.
Does ESP32 also support this ??
Cool i got an idea.
I would connect that to a wifi board the i will be able to upload sketches over the air from the cloud.
So now i can control many of the smart displays like showing and typing things on them.
All from my control room!
Thanks mate.
Very very good tutorial! Thank you!
Thanks Wayne!!
Thank You
Thanks a ton for watching - I hope you found it helpful!
This was very helpful, thank you!
Glad it was helpful! Thanks a ton for watching!
love this video exactly what i needed !!!!!!!
Great! Good luck on your project John!
Keyboard library didnt work in arduino uno nano but may worknif i change ots bootloader
I believe these USB libraries will only work on boards using the 32u4 or SAMD micros. If I am not mistaken, I think Nanos use the 328p micro.
Very nice! I was using a HID rubber ducky to TAB and ENTER thru Facebook menus of bots to report all their bot friends as fake accounts. Adding a button would make it smoother to use!
Glad that someone is doing this. Too much fake news.
Love your videos. Thank you for helping
Thanks!
That's cool Bro!!! Thanx a lot!!
Thanks for watching!
can you explain how to use keyboard.h with the matrix sistem?
Is there a way to do this without a physical arduino button? Because it would be quite nifty to be able to bind this process to a key on my keyboard, thanks.
Autohotkey. It can emulate a keyboard and do a lot more at the touch of a key. It can maximise and minimise windows; it can open, move, copy, and delete files; it can run programs, with or without arguments; it can detect the colour of a pixel on the screen; and a lot more. It can also do different things dependent on context. The context can be whether a file exists, a certain window is open, a certain window is active, and so on. It beats the Arduino hands down. I couldn't live without AHK. It has saved me millions of keystrokes and mouse clicks.
Is there a way to do this on the Arduino Uno R3?
I can be done, but it would be very tricky and non-standard.
arduino.stackexchange.com/questions/991/can-the-2nd-mcu-on-the-uno-r3-be-used-for-keyboard-emulation
Excellent video, very clear explanation. But if I don't have a Kit-On-A-Shield, would making a connection with a switch between pin 5 and ground be enough?
Great question Dardo! I should have been more clear about that in the video.
You should probably add to that a ~10K pull down resistor from pin 5 to ground as well.
@@programmingelectronics Is it possible for the plate to burn out if I do not connect the resistor? Because I saw other tutorials in which they connected the pin directly to ground, in that case it was an arduino pro micro board which is the one I bought. I'm new to this, sorry if my question is too obvious.
@@dardodiesel5502 Great question! There would be no harm done to the board/circuit/button/etc if you did not connect the resistor.
This gets a bit convoluted, but...The resistor recommendation was to make sure that your input pin was "pulled down" when not being pressed - that is, so when you are not pressing the button that it reads a LOW voltage. It may already be showing a LOW voltage when the pin is not pressed, but the pin is in a "floating" state if it's set to an input and not connected to a voltage source (aka, ground or 5V). Now what you could do, is sett the input pin to an INPUT_PULLUP using the pin mode function, and then instead of hooking your button to pin 5 and 5V, you connect it to pin 5 and ground. In this case, when you don't press the button, it would read HIGH, and when you press the button it would read LOW, so you just need to adjust your logic in this if statement to trigger on LOW. Sorry for the run on - hope it helps some!
@@programmingelectronicsThank you very much for taking the time to answer! Your explanation helped me a lot.
@@dardodiesel5502 Great!
Can you somehow asign additional f-keys to those buttons and like a mouse-wheel to a potentiometer?Would be very nice, because then it could work as a editing keyboard for davinci as an example.Very nice video btw!
I think that is very doable. I think you might consider a rotary encoder over a potentiometer for the spin action, but in general, yes, totally possible.
@@programmingelectronics Yes, after a bit of researching that seams like the best option. Not quite sure how to set this up in my editing Software(Davinci), but il find a way.
Is there a way to make a key to do a Command C (copy) for the Mac? On the runaway problem, I just added a 5-second delay in setup. I used the pro micro to make a programmers keypad, so I have separate keys for (), {}, < > etc. works great.
Thanks for adding that about the runaway problem V J!
As for the copy (and maybe paste as well?) I have not tried this, but I think you would use the press command, the appropriate modifier keys, and then the release command. That would be fun to try!
Press-> www.arduino.cc/reference/en/language/functions/usb/keyboard/keyboardpress/
Modifier Keys -> www.arduino.cc/reference/en/language/functions/usb/keyboard/keyboardmodifiers/
@@programmingelectronics Yes, but I don' think one can simulate a 'command' button because its some kind of key for the OS only, as far as I can tell. Thanks.
Hi @@TheUnofficialMaker - I just check on this, and looks like it is KEY_LEFT_GUI or KEY_RIGHT_GUI to press the CMD Key on Macs - I have it working in a simple sketch to copy and paste a line of text. I'll see if we can get a short video showing how as well - thanks for the great questions!!
could you attach a 16 button keypad for 16 cusom functions?
That's the exact kind of thing I have in mind as well! As long as you could register each press, you could assign it a specific task using the library.
So do you connect the Arduino to one USB port on your computer and your actual keyboard to another USB port on your computer? Or do you connect the Arduino to a USB port on the computer and you somehow plug your actual keyboard into the Arduino and the Arduino “passes thru” keyboard presses on the keyboard thru to the computer?
Great question! You just keep your normal keyboard plugged in and it works fine. The Arduino then acts as an additional keyboard.
So, (14:30) how did you reprogram the board to stop the key entry or mouse movement? You mentioned that you tried to upload a new sketch. Is the solution to upload a new "bare minimum" sketch?
Great question! You can upload any sketch that allows you to get back keyboard/mouse control - the "bare minimum" would be a great option, or you can just comment out/change the lines of the current program, so as not to use the keyboard/mouse.
@@programmingelectronics That's still not the answer to the question Keith had and I still have, that you can program the bare minimum sketch or to comment out the problematic line of code is the most logical thing to do, but if the Arduino is causing havoc to the input of your computer and really doing something that makes it impossible for you to do anything yourself with your mouse or keyboard.
Let's say we are in a hypothetical worst case scenario and as soon as you plug in your Arduino it makes everything you want to do impossible and there's nothing you can do, other than unplugging the Arduino to get back the control over your computer, do you have to consider the Arduino to be unusable from that point or is there something you can do to either block the Arduino from taking over your keyboard and or mouse or is there a way to reprogram the Arduino without plugging in the USB connector?
If I would start tinkering with this keyboard and mouse library for the Arduino, I for sure as hell would have made something either in software that can deal with a worst case scenario to prevent the Arduino from causing havoc or I would made something in hardware that has one very important task which is connect to the Arduino and instantly uploads a minimal sketch, and this would always be ready to use and in close proximity.
While I'm writing this comment I realize that I came up with the answer myself.
>> HERE IS THE 5 STEP SOLUTION
@@RicardoPenders Awesome! Thanks for adding all these details and steps!
If you find yourself with that type of runaway situation you can press and hold the reset button on your Arduino, the Arduino sketch won't run while the button is held in. Click load on your IDE and simultaneously release the reset button. Hope this helps.
I would like to make a macro to repeat actions within a video game, is it possible using Arduino?
Please how to instal keyboard.h library
Hello, grate video, but can you help me whith the keyboard.press(); command, i realy want to doo that, If you see this, pls reply
Maybe this this video can help?
ua-cam.com/video/29QYRpppHv8/v-deo.html
I'm using your code but it keeps running without hitting the button why is that
Nice tutorial! 👍 What about Unicode characters? Is it possible to press them using hex or binary code?
Great question! I am thinking you could send a a unicode symbol using the keyboard.print() function, but I'll have to check.
www.arduino.cc/reference/en/language/functions/usb/keyboard/keyboardprint/
How would I use rf24 to set pins high or low using 2 Arduino unos and a laptop?
Great question! Can you expand a little on the application?
thank you
Thanks so much for watching!
Can i use arduino uno or nano🥺🥺
Unfortunately not Yash.
@@programmingelectronics 🥺🥺🥺🥺
I can’t seem to figure out how to
(action press down) copy ;
(action release button) paste.
Any hints? Perhaps a video in the future?
I’m able to to copy paste from 2 seperate buttons but this one had me confused.
You may want to try a button debouncing library. With the the Bounce2 library, for example, you can write:
button.update();
if (button.fell()) {
Keyboard.press(KEY_LEFT_CTRL);
Keyboard.press('c');
Keyboard.releaseAll();
} else if (button.rose()) {
Keyboard.press(KEY_LEFT_CTRL);
Keyboard.press('v');
Keyboard.releaseAll();
}
Will any of this work with a DOS computer?
Great question - I am not sure!
Can the Arduino emulate other special keyboard keys that don't seem to have predefined constants in keyboard.h (for example, sleep , multimedia keys, PrtScn, and differentiate between main keyboard numbers vs "number pad" numbers)? Is yes, how can we find out what codes to send so we can augment the built in constants with our own? What about maybe trying to find it out by building a keylogger. I suppose I would need to add a host USB port to the Arduino. But can you use a host port and device port at the same time? Or even better, can I control the function of the USB port on my Leonardo and "toggle it" between host port and device port behavior?
Version 1.0.4 of the Keyboard library brings a few more key macros, including KEY_PRINT_SCREEN and all the keys of the numeric keypad. You now have all the keys of a “standard” full-size PC keyboard. No Sleep or multimedia keys though.
I do not think an Arduino can be used as an USB host. The SAMD based-ones maybe, but not the Leonardo.
Can i use it for ps4 or Xbox
Thanks for this nice tutorial. I'm trying to emulate the keyboard library in Bluetooth HID. Tried bleKeyboard library for ESP32 but unfortunately the esp is not connecting.
Can you recommend a different library for ble Bluetooth?
Thanks
Hi Sam, I am working through similar issues right now (you are not alone!), hopefully when I get to the light, I'll be able to post something here!
This would work with the 2560 Mega right?
Unfortunately no. These libraries only work with boards that are recognized as HID (human interface devices)
Thank you so much for responding,
There's no way i can add some library? There must be. @@programmingelectronics
I don't think so, but I could be mistaken for sure. @@theunofficialprofessional Maybe this is worth exploring? www.instructables.com/How-to-Make-a-Arduino-HID-Keyboard/
Best of luck!
can i also use an arduino uno
?
Does anyone know a modification to this code that would work, I want to use my keyboard keys and not a arduino button
Hi. I did not see your video in time. Sure enough that’s what happened. Took some time to get it straighten out. Thanks. If I could ask a question on if else statement. I have nested if- else statements 3 deep. When coming out after executing the inside statement, does the program flow skip over any ‘else’ statement it finds coming out though the outside ‘else’ statements. If that makes any sense
Is there a good way to get out of this keyboard lock. Just happened again and whatever I did last time to get out of it I cannot replicate getting the Arduino to again accept downloads. Sorry for the trouble. Wayne
You did not mention Arduino Uno and Mega boards. Do they work with it as well?
Great question! They do not work with this library.
@@programmingelectronicsbut this is not anymore the case with UNO rev4 right?
Can it also appear as a native keyboard and mouse like 32u4 and SAMD based boards?
@@RobinHood-zi9ctThat's right! I believe the new R4 UNO's should work with these libraries.
sir can you help me for my project ?? I have a project to make digital scales, but here I need a tool to enter an address,,
can you help me to program a keyboard so that it can connect to the arduino and work
Wonderful
Thank you! I hope it helps!
And how do you do this "outcommenting" of several lines at once with double slash?
Great question!
If you select multiple lines, and use "Control + /" on PC, or "Command + /" on macOS, it will comment multiple lines. If you select commented lines, and then use the same keyboard shortcut, it will toggle back to un-
comment
@@programmingelectronics thank you! I learned something today!
@@Pit.Gutzmann awesome - glad it helped!
do arduino megas work with this?
Great question Alend! Unfortunately no, Arduino MEGAs will not with this keyboard library.
@@programmingelectronics Do you know of any way that I could replicate this without the keyboard library?
been having a hard time finding how to do with with more than one button. I have a box I made and did this in the past.. but I cant find my project file or resources on how to do it so far! I know it isn't that hard.. but I cant figure out how to do it so far... I have 10 buttons setup in a non matrix style all of the buttons have pull up resisters on it already... plugged into a leostick ...Any ideas?
Great question - I've been wanting to build a custom keyboard emulator myself for some specific key presses.
Basically, you just need to read button presses in the loop, and when a specific button is pressed, you have you code execute that keyboard command. It can get a little tricky, because you want to make sure a button press is only registered once per press, and that button presses don't get missed if you're doing other stuff in the program.
I'll see if i can come up with something for this one...
How many characters it can type in one second?
Not sure - it would be limited by the speed of the loop.
This is great :)
It doesn't work for me at all. I'm using MKR WiFi 1010
Does it really send keystrokes or just copy paste
Good question! I am pretty sure it is sending the keystrokes.
@@programmingelectronics did you test it by using keyslogger
guys I get error Compilation error: keyboard.h: No such file or director how do I fix it?
Great question! What board are you using?
@@programmingelectronics uno 3
@@Qwzdf Unfortunately, these libraries will not work on an Arduino UNO.
@@programmingelectronics will it work on the MEGA? im considering buying it, also which ones are supported?
Great question @@TriflingToad ! A Mega will not work with this library. An Arduino Leonardo would work.(Zero, Duo, and MKR family)
do it also work in aurdino uno ?
On the UNO R3 no, but it would work on an UNO R4
Thank a lot
came for see is arduino i have can be use as keyboard. suddenly learn how to make it. tbh it kinda same as keyboard library from python. wonder if they are made by same guy
anyway if you still use a macro or other people plan to make macro like this. im suggesting using python library and bind it to function key like F12 or F1. or maybe just like me using macro keyboard to add F13 and F14(yes it does exist and yes it registered on windows. the only way i know to make this by print it with python script while record macro key on my keyboard. and waila you have extended Function key)
by doing this you make 0$ macro function instead buy Arduino and buy a button.
but sure having keyboard library on Arduino does kinda help if you want to fix old expensive keyboard but chip broken.
im actually planning fix my keyboard that why im coming here to make sure is my board compatible with library
Hopefully this doesnt get used for any sort of malicious purposes any time soon 😈 (jkjk good video though thanks, really helped me get started with it. Been using this for a custom keyboard ive been making out of a repurposed type writer I find. Really helps with macros especially custom ones for VIm. )
will this work on Arduino Uno??
It will work on an UNO R4, but not the more common UNO R3
Hola, al ver este video que me ha encantado porque creo que es la solución que andaba buscando varios meses, al fin me parece que voy a solucionar mi problema, gracias y te voy a preguntar si el posible lo que quiero. Hace años compré una aplicación de música STYLE WORK XT y al cambiar de ordenador la aplicación me pide un nuevo pin, escribí varias veces al vendedor, pero me enteré que este señor había fallecido, con lo cual no puedo utilizar esta aplicación. PREGUNTA: si me hago una aplicación en arduino, crees que puedo ir generando pines en la ventana de esta aplicación como si las fuera tecleando manualmente? solo necesito enviar NUMEROS y usar la tecla INTRO, FLECHA IZQUIERDA Y FLECHA DE BORRAR.
Buen proyecto! Sí, eso suena posible. Vea también los otros videos que tenemos sobre el uso de teclas especiales. ¿Vas a escribir un programa que intente muchas combinaciones de pines hasta que encuentres el pin correcto?
ua-cam.com/video/29QYRpppHv8/v-deo.html
@@programmingelectronics Si eso es lo que intento, ya hice uno con relé de 16 canales soldando a un teclado viejo y funcionó, pero el relé se quemó porque es un pin de 6 dígitos. Voy a ver todos los videos y ya te contaré. Gracias por contestar
Gracias por darme ánimos, seguí probando y al final lo he conseguido, saludos
The „normal“ Arduino Uno doesn’t work, right?!
That’s correct, this library requires an Arduino that can act as a USB emulator.
@@programmingelectronics thank you for answering! 🙏🏼
@@pixelgrafik1146 Happy to help!
You don t need an arduino to do that. Just run a script on your pc.
You're right! Could run a script on a mac as well. The idea is being able to use external hardware to trigger such tasks, aka, button presses, sensors, etc.
bro nice nice nice nice nice nice nice nice nice nice nice nice nice nice nice nice nice nice nice nice nice nice nice nice nice nice very very thank you so much bro 🔥🔥🔥you won my heart
Glad you liked it!
If you're on Windows just use AutoIt, far more elegant solution than plugging an arduino to simulate a keyboard!
AutoIt is good but obsolete. There's Autohotkey now.