Arduino Tutorial #11: Leonardo as Keyboard

Поделиться
HTML-код
  • Опубликовано: 26 сен 2012
  • In today's Arduino tutorial, we look at the Leonardo's built in USB emulation capabilities. Specifically, generating keyboard output. Remember that it is a good idea to add a switch to your code to ensure that the board stops acting like a keyboard, so that it can be reprogrammed.
    Have a question you'd like answered, now you can email me directly at:
    humanharddrive@gmail.com
    Or post your suggestion for a future video below.
    List of "Special Keys":
    arduino.cc/en/Reference/Keyboa...
    Kudos to Roland Gyorgypal for letting me use his iPhone.
  • НаукаНаука

Комментарии • 92

  • @miguelangelmartinezcasado8935
    @miguelangelmartinezcasado8935 6 лет назад +2

    So many thanks for everything. I was trying to automatize some RPG games and I had an Leonardo, and it seems soooo easy now to automatie everything.... Thanks!

  • @KasisnuSingh
    @KasisnuSingh 10 лет назад +31

    Just a quick thing to try if you manage to get yourself stuck in a position where the Leonardo can no longer be programmed. Hold down the reset button, plug the board in, hit upload and release the reset button! Your new code should get uploaded. This might save you some serious time! :)

    • @SarahC2
      @SarahC2 8 лет назад +2

      +Kasisnu Singh Good to know for when mine arrives, thanks!

    • @pepijn_m
      @pepijn_m 7 лет назад +2

      thx will test this at home

    • @LeandroLinares
      @LeandroLinares 4 года назад +1

      You just saved my life right now

    • @renejavion345
      @renejavion345 3 года назад

      I realize I'm kinda randomly asking but does anyone know of a good site to watch new movies online?

    • @ahmedmatias4086
      @ahmedmatias4086 3 года назад

      @Rene Javion lately I have been using Flixzone. You can find it by googling :)

  • @letsgoBrandon204
    @letsgoBrandon204 8 лет назад +4

    Am I correct in thinking that the 'while (digitalRead(2))' line means that while pin 2 is connected to GND it behaves like a USB keyboard. Disconnect it and it becomes programmable again?

  • @rupertrussell1
    @rupertrussell1 11 лет назад +1

    I can't wait to give this a try. I ordered one of these boards today.

    • @foxfirefive
      @foxfirefive 3 года назад +1

      they are very fun. i hope you have fun :)
      heres something you could try btw, a joystick mouse cursor. it needs a joy stick though.

  • @azrilazraei7954
    @azrilazraei7954 8 лет назад +1

    Can you help me with a coding if i move one flex sensor, it would press a certain key on the keyboard. the flex sensors acts as the input. i'm trying to build an flex sensor gloves as controller to play pc games. thankyou

  • @leocantug2
    @leocantug2 8 лет назад

    This is a great lesson, simple and effective ! Thanks...

  • @fastjonny05
    @fastjonny05 8 лет назад

    when I try it says 'keyboard' not found. Does your sketch include the line '#include '?
    if i add it, it says "exit status 1 stray '#' in program" PLEASE HELP

  • @msjaxp
    @msjaxp 11 лет назад +1

    Go on dude
    Your now number one in RUclips in Microcontroller tutorials
    Viva Humanharddrive :)

  • @samuelmarek8760
    @samuelmarek8760 7 лет назад +1

    I have a german keyboard so when tell the arduino leonardo to write a hyphen it puts something else how can i change the keyboard layout in the arduino ide?

  • @stevefonseca9469
    @stevefonseca9469 7 лет назад

    A week ago I followed your example. Thanks for teaching. Today my windows 7 PC does not see the Leonardo. It just shows COM 1 (generic). I plugged in a Uno and it shows up as COM4. Any thoughts?

  • @920PC
    @920PC 7 лет назад +6

    GREAT walkthrough for beginners on Keyboard/Mouse emulation! Thank you for the video!
    NOTE: You must have a leonardo board (or other ATmega32u4 processor board) selected in ArduinoIDE to be able to compile this.
    Question:
    How did you get it to compile without "#include "Keyboard.h""??

    • @gonzatta
      @gonzatta 9 месяцев назад

      Because it's an old video, we now have to include the library, but back then we didn't have to.

  • @MasoodOfficial
    @MasoodOfficial 4 года назад

    Plugging it in some random windows PC does it ask for driver or anything special software like Arduino IDE it self to be installed in order to work?

  • @carpenterfamily6198
    @carpenterfamily6198 5 лет назад +1

    Is there a way to user define the delay between each character sent in a string ?

  • @derFleder
    @derFleder 8 лет назад

    Hello there, might i ask you to explain this jumper mechanic more in depth? Do i only have to connect a pin to GND or do i also have to write some code for this to work?
    I have a arduino leonardo clone, which has got no button for going into programming mode, so i am highly interested in your solution. Thank you and regards.

  • @brianpacheco1927
    @brianpacheco1927 7 лет назад

    So let me get this straight when you shorted it out did you short ground or the digital pin? Trying to understand a key press would activate the key input on the digital input.

  • @redeyerob2176
    @redeyerob2176 4 года назад

    So i have a arduino leonardo pre set up as a sim button box, now is there any way to set up one of the rotary encoders as a windows media player volume knob without affecting the rest of the buttons on the arduino, kind of scared of trying to mess with it as the unit in contained in a sealed box so i cant get to the board easily if i need to reset it?

  • @FutureInventions
    @FutureInventions 11 лет назад

    Excellent video. Thanks so much for this! I'm getting a Leonardo for my projects. I'm going to make a really awesome gaming controller with this! :D

  • @ematech
    @ematech 5 лет назад

    how to emulate keypress F1? and key combination like ctrl + alt? and with a potentiometer emulate key left right changing?

  • @aoeu6092
    @aoeu6092 10 лет назад +3

    Can you explain the purpose of your while-loop in this video. I understand it returns a boolean, but isn't the scope of that boolean only within the while-loop (in which you have written nothing). I have seen you written similar empty while-loops in other videos and I can't understand why?
    Thank you for the great tutorials :)

    • @humanHardDrive
      @humanHardDrive  10 лет назад +4

      It's just to create a simple wait. It sits in the loop until pin 2 is pulled low. Then it executes the rest of the code. It's basically just a start button.

  • @humanHardDrive
    @humanHardDrive  11 лет назад

    I've used my Leonardo on a 3.0 port without any difficulties. Did you install the drivers for the device before trying to upload code to the board?

  • @TodmordenFred
    @TodmordenFred 3 дня назад

    I liked this. But couldn’t find the follow up video regarding the addition of mouse and joystick.
    As I’m interested in utilising a cheaper option to control a retro arcade fight stick panel over the PAC-4 controller board

  • @markstevenson621
    @markstevenson621 8 лет назад

    Is this leonardo ardiino can convert zx spectrum in to a usb keyboard with this

  • @donnymontreano2045
    @donnymontreano2045 4 года назад

    in 0:38, is DUE does the same jumper ? and in the same Pin as well ? thank you ?

  • @Shafeeq_Muhammed
    @Shafeeq_Muhammed 3 года назад

    Can you please explain how Keyboard Matrix works and How to program in Arduino for 12x6 Matrix Keyboard

  • @g1expert102
    @g1expert102 Год назад

    I was trying to write code for my arduino. I was building a button box
    But it went all crazy and whenever it was plugged in it would just start registering key presses and it filled the programing ide with nonsense
    I had to find a way to reprogram it while it was registering a key press

  • @VenkateshDhara333
    @VenkateshDhara333 9 лет назад +1

    actually i forgot configure second pin in programing so iam not able to upload new code

  • @themanthis837
    @themanthis837 9 лет назад

    so you disconnect the jumper & then it sends the keystrokes once?

  • @rfresh1011
    @rfresh1011 8 лет назад

    So, I assume when you run your sketch to send out key strokes, the windows application that has the focus is the app that receives the key strokes, right?

  • @Shawn_White
    @Shawn_White 11 лет назад

    1:10 if you lock the chip by leaving it in 'USB' Mode you can always re flash the boot loader with the ISP header. You can even use the other arduino as an ISP programmer.

  • @humanHardDrive
    @humanHardDrive  11 лет назад

    What error is popping up?

  • @CERN1954
    @CERN1954 11 лет назад

    Yes I have install the driver manually when it was connected to the USB 2.0 port. When I tried to install driver for the USB 3.0 manually, an error message poped up saying can't find the driver... (I'm using Windows 7 laptop)

  • @moustafarefaat6155
    @moustafarefaat6155 7 лет назад +1

    i did every thing u said it give this msg (exit status 1
    'Keyboard' not found. Does your sketch include the line '#include
    '?) what should i do and im working with arduino
    leaonardo !

  • @geofish101
    @geofish101 11 лет назад

    would the press command work for say "CTRL C" if you did,
    "keyboard.press(CTRL)
    keyboard.press(C)
    keyboard.releaseAll"
    Would this work?

  • @frNNcs
    @frNNcs 7 лет назад

    Will it works with Arduino Mega ? Because its gives me this compilation error "exit status 1
    'Teclado' no encontrado. Tu sketch incluye la linea '#include '?"

    • @humanHardDrive
      @humanHardDrive  7 лет назад +1

      No. This only works with Arduinos based on the 32u4 processors such as the Leonardo, Due, and the Zero.

  • @KevAdams1989
    @KevAdams1989 11 лет назад

    do you think i could make a prank with this where i plug in a usb with .doc or .txt file and make a computer type things out on the screen from those files one letter at a time?

  • @ArielBaravalle
    @ArielBaravalle 6 лет назад +1

    Hello , good video ! thanks for you time.
    How print or write "arroba" (or "at" in english )?? I need write a email
    I have tried different ways but I can not get it.
    can you help me ?

    • @ArielBaravalle
      @ArielBaravalle 6 лет назад

      I resolve the problem to print "at"
      Keyboard.press(KEY_LEFT_CTRL); // send Hex value for RETURN key
      Keyboard.press(KEY_LEFT_ALT); // send Hex value for RETURN key
      delay(500);
      Keyboard.write(50);
      Keyboard.releaseAll();

  • @TiffJimber
    @TiffJimber 9 лет назад

    Great Vid. Keep em' coming
    Tiff Jimber
    Indie Musician and ewok lover

  • @LoLhashbrownx
    @LoLhashbrownx 8 лет назад

    'keyboard' not found. Does your sketch include the line '#include '?
    How do i solve this problem?? i did everything the same as the video but this error comes up when i tried to compile
    Tried including the line #include ; in the code but it just gave me an error while compiling

    • @jimbofarrar6691
      @jimbofarrar6691 8 лет назад

      +Cyrus Li Try with the letter k in uppercase : Keyboard

  • @mattiaskundert7717
    @mattiaskundert7717 7 лет назад

    can i get the code please?

  • @JustinDiazJokes
    @JustinDiazJokes 8 лет назад

    so the leonardo is the only board that can do this? i wanted to buy a pro mini and make it control a bunch of stuff.

    • @Dextermorga
      @Dextermorga 8 лет назад

      +Luis Valdivia All boards with ATmega32U4 micro-controller.
      www.arduino.cc/en/Products/Compare

    • @pepijn_m
      @pepijn_m 7 лет назад

      I think pro micro works too. pro mini doesn't have a usb interface so it wont work

  • @eutimputnoki6912
    @eutimputnoki6912 8 лет назад +1

    +humanHardDrive
    is this going to work with arduino uno?
    when i try i get this error message:
    Arduino: 1.6.6 (Windows 10), Board: "Arduino/Genuino Uno"
    C:\Users\MR3SUP~1\AppData\Local\Temp\arduino_80cfdf8b7d8b12157ca53897bc597d72\sketch_dec25c.ino: In function 'void setup()':
    sketch_dec25c:6: error: 'Keyboard' not found. Does your sketch include the line '#include '?
    Keyboard.begin();
    ^
    sketch_dec25c:14: error: a function-definition is not allowed here before '{' token
    void loop() {
    ^
    sketch_dec25c:18: error: expected '}' at end of input
    }
    ^
    exit status 1
    'Keyboard' not found. Does your sketch include the line '#include '?
    This report would have more information with
    "Show verbose output during compilation"
    enabled in File > Preferences.

    • @zachtbsa3791
      @zachtbsa3791 8 лет назад +1

      +Eutim Putnoki I don't think that arduino uno has the capability to upload to computer. You have to have the leonardo.

    • @eutimputnoki6912
      @eutimputnoki6912 8 лет назад

      +zBon3s yes I already found out, but still thanks for your response!

    • @eutimputnoki6912
      @eutimputnoki6912 8 лет назад

      +zBon3s yes I already found out, but still thanks for your response!

    • @eutimputnoki6912
      @eutimputnoki6912 8 лет назад

      +zBon3s yes I already found out, but still thanks for your response!

    • @eutimputnoki6912
      @eutimputnoki6912 8 лет назад

      lol sorry there was a connection error, so i touht my comment wasnt send ^^

  • @guzmadera
    @guzmadera Год назад

    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.

  • @HarryDigsHoles
    @HarryDigsHoles 8 лет назад

    can someone give me a reason as to why this would not work on an arduino uno, and if possible a fix so that i can imitate a keyboard on the uno

    • @FriendZoneLiam
      @FriendZoneLiam 8 лет назад +1

      +Spoderman from what i have gathered its something to do with the chips that talk to the usb and the micro processor, the chip used in the uno doesnt allow it to act as a usb input device, but there is something called v-usb that might work for you

    • @HarryDigsHoles
      @HarryDigsHoles 8 лет назад

      FriendZoneLiam ok, thanks

  • @FuZZbaLLbee
    @FuZZbaLLbee 2 года назад +1

    I used this to connect an old Amiga keyboard to my PC. That keyboard wasn't used for 30 years.

  • @prashantthapliyal5449
    @prashantthapliyal5449 5 лет назад

    But how can one emulate entire keyboard like this?

  • @humanHardDrive
    @humanHardDrive  11 лет назад

    YES!! DO IT!!

  • @VenkateshDhara333
    @VenkateshDhara333 9 лет назад

    my arduino is continuously sending the keys so that iam not able to upload new code even i connect pin2 to ground

    • @humanHardDrive
      @humanHardDrive  9 лет назад

      Venkatesh Dhara The pin shouldn't be connected to ground. Connect the pin to 5 volts so the keyboard isn't enabled on power.

    • @VenkateshDhara333
      @VenkateshDhara333 9 лет назад

      Venkatesh Dhara problem solved i had erased the rom using avr programer

  • @ismaelsoum6401
    @ismaelsoum6401 9 лет назад +3

    that is cool but i didnt get why you connected pin 2 to ground.

    • @darlistener6671
      @darlistener6671 9 лет назад +5

      Ismael Soumahoro because the arduino should check if this cable is connected. if it is, the arduino will no execute the program so that you can reprogram it.

  • @CERN1954
    @CERN1954 11 лет назад

    Do you know if Arduino Leonardo supports USB 3.0?

    • @pepijn_m
      @pepijn_m 7 лет назад

      all usb2 devices should work on usb3 its back ward compatible

  • @InspirationalQuotes480
    @InspirationalQuotes480 7 лет назад

    What do I use if I want to use FN? I can not find it in the "special key'

    • @Shmoozo55
      @Shmoozo55 6 лет назад

      Don't. Use the code for whatever key you are trying to emulate with the Fn key combo.

  • @mr.nobody6829
    @mr.nobody6829 7 лет назад

    keyboard.println("I am sick and can't stop coughing")

  • @Dark-uh6sc
    @Dark-uh6sc 6 лет назад

    nano?

  • @tiesdevos6897
    @tiesdevos6897 7 лет назад

    can i do this with my uno?

    • @tbollenbach5536
      @tbollenbach5536 7 лет назад

      You can but from my understanding its a lot more difficult.

    • @pepijn_m
      @pepijn_m 7 лет назад

      as far as i know uno uses serial to connect to the computer etc. it doesn't connect direcly to the pc

  • @unlokia
    @unlokia 7 лет назад +1

    Dude, could you typo "Keybarod" ANY MORE times? Hehe. 😉

  • @valipdr541
    @valipdr541 10 лет назад +1

    Guys don't do anything stupid with that function !
    I loop on ctrl+alt+delete by accident (that's coding at 4am after a few blunts^^)
    I can't even know how i did to "reset" the code, everytime i pluged it to the computer, it's was lala land :D

  • @t18000
    @t18000 9 лет назад

    to run the code each time pin 2 and gnd is conected just put the code in void loop () example:
    void loop()
    {
    while(digitalRead(2))
    {
    }
    Keyboard.println("HELLO WOLD");
    delay(1000);
    Keyboard.println("I AM ALIVE");
    delay(2500);
    Keyboard.write(48);
    delay(2500);
    Keyboard.press(KEY_BACKSPACE);
    delay(5000);
    Keyboard.releaseAll();
    }

  • @mattnavarro3675
    @mattnavarro3675 4 года назад

    You don't say anything I conceive, I thought your explanation would help me because I want to emulate a keyboard that will only have 6 buttons for a game. of reactions and responses. but you don't say anything about it if you know how I would appreciate it.