Navigation

    LILYGO

    • Register
    • Login
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups

    Can't upload sketch after using Lilygo as a USB keyboard and mouse emulation

    Common problems
    2
    2
    268
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • F
      franic last edited by

      I have uploaded a sketch that transform my lilygo ESP32-S3 in a USB keyboard and mouse emulator
      The sketch works, but I can't upload a new sketch as the serial port is then disabled.
      How can I erase the sketch or upload a new sketch ?
      Is it possible to have serial port and USB keyboard and mouse emulator at the same time ?
      (It's possible with an ardunion leonardo)

      #include "USB.h"
      #include "USBHIDKeyboard.h"
      #include "USBHIDMouse.h"

      USBHIDKeyboard Keyboard;
      USBHIDMouse Mouse;
      uint8_t buf[200];
      void setup() {
      // open the serial port:
      Serial.begin(115200);
      // initialize control over the keyboard:
      Keyboard.begin();
      Mouse.begin();
      USB.begin();
      Keyboard._onGetDescriptor(buf);
      }

      void loop() {
      // check for incoming serial data:
      if (Serial.available() > 0) {

      // read incoming serial data:
      char inChar = Serial.read();
      Serial.print(inChar);
      // Type the next ASCII value from what you received:
      Keyboard.press(inChar);
      Keyboard.releaseAll();
      

      }
      Mouse.move(20, 20, 0, 0);
      Keyboard.press('Q');
      Keyboard.releaseAll();
      delay(3000);
      }

      1 Reply Last reply Reply Quote 0
      • teastain2
        teastain2 last edited by

        You need to enter upload mode by first pressing Boot, then press and release Reset, then release Boot.
        After upload you may have to unplug the board and plug it back in.

        You can also "erase all flash before uploading" but it takes a long minute!

        I have no experience with keyboards and mouse on ESP32, as I consider a Rasp pi a better choice for 'that sort of thing'.

        1 Reply Last reply Reply Quote 0
        • First post
          Last post
        Powered by NodeBB | Contributors