Arduino as mouse on Arduino IDE computer broken?

first the arduino nano 33 iot was one device and example blink program worked properly.
then some serial output did not appear into the ide, so after setting up Serial.begin(9600) there was a second com port in windows 11, and it has the cannot start warning.

now the programming of the device works, but serial output does not work (only first serial text shows up). also the ide claims the upload does not work, there is an error.

how can it be so easy to break the functionality?

edit:
now the serial output without serial initialization works. I already tried to uninstall both of the usb port devices, but windows adds them back when re-connecting the device. Still the main arduino device in windows has the warning label (COM12), and the serial is a separate port (COM11). now the programming warning went away. Programming works only on the COM11 device, not on the named COM12 device.

Hi, Welcome to the community!
provide as much as details you can,
codes, error messages, and other necessary details!

can you say anything based on the current lacking information?

now after opening an example, the blink, it changed the com port to COM9 and removed the two COM11 and COM12, on windows 11.

Serial output is not working clearly on win11.

If you are not supposed to put IMU.begin() in the main loop, then your examples are misleading, with the "..." and the IMU.end() block.

Well now, removing the #include <Mouse.h> resolved the issue, so that library is not working properly on windows 11.

seems like the only real problem is with the "include <Mouse.h>" and the win11 drivers. disregard the others.

1 Like

Hi again,

seems like win11 does not add the arduino nano 33 iot as HID device, it tries to, when the mouse.h library is added to the code. what if this a win11 driver issue, HID issue, not the code issue.

consider the following mouse prototype code:

#include <Mouse.h>
#include <Arduino_LSM6DS3.h>
float ax=0.0f, ay=0.0f, az=1.01f, tol=0.005f, ltol=0.1f, dec=0.99f, mlt=1000000;
void setup() {
  pinMode(LED_BUILTIN, OUTPUT);
  if (!IMU.begin()) {
      while (1);
  }
  Mouse.begin();
}
void loop() {
  float x, y, z; float fps; float dx, dy, dz, dt; int mx, my, mz; bool mousemove = false; bool mouselift = false;
  if (IMU.accelerationAvailable()) {
      IMU.readAcceleration(y, x, z); fps = IMU.accelerationSampleRate(); dt=1.0f/fps;
      ax=dec*ax+(1.0f-dec)*x; ay=dec*ay+(1.0f-dec)*y; az=dec*az+(1.0f-dec)*z; dx=x-ax; dy=y-ay; dz=z-az;
      if (abs(dx)>tol) { mx=mlt*0.5*dx*dt*dt; mousemove = true; }
      if (abs(dy)>tol) { my=mlt*0.5*dy*dt*dt; mousemove = true; }
      if (abs(dz)>ltol) { mz=mlt*0.5*dz*dt*dt; mouselift = true; }
      if (mouselift) {
        digitalWrite(LED_BUILTIN, HIGH);  // turn the LED on (HIGH is the voltage level)
      } else {
        digitalWrite(LED_BUILTIN, LOW);   // turn the LED off by making the voltage LOW
        if (mousemove) {
          Mouse.move(mx, my, 0);
        }
      }
  }
}

again, it works as a mouse on a non-arduino IDE computer, not on the development computer, for some reason. any specific reason the arduino device/IDE should act like this?

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.