#include "Keyboard.h"
      void setup() {
         // open the serial port:
         // initialize control over the keyboard:
      void loop() {
         // check for incoming serial data:
         if (Serial.available() > 0) {
            // read incoming serial data:
            char inChar = Serial.read();
            // Type the next ASCII value from what you received:
            Keyboard.write(inChar + 1);
      Cpp language logo

      Arduino - Keyboard Serial


      This example listens for a byte coming from the serial port. When received, the board sends a keystroke back to the computer. The sent keystroke is one higher than what is received, so if you send an "a" from the serial monitor, you will receive a "b" from the board connected to the computer. A "1" will return a "2" and so on.

      Warning βˆ’ When you use the Keyboard.print() command, the Leonardo, Micro or Due board takes over your computer's keyboard. To ensure you do not lose control of your computer while running a sketch with this function, set up a reliable control system before you call Keyboard.print(). This sketch is designed to only send a Keyboard command after the board has received a byte over the serial port.


        Add Comment

        Log in to add a comment

        Codiga - All rights reserved 2022.