Avrdude: ser_open(): can't set com-state for "\\.\COM7"

Hi @fisheee1230.

Please try this:

I'll provide instructions:

  1. Connect the Arduino board to your computer with a USB cable.
  2. Open the Windows Device Manager.
  3. Select View > Devices by type from the Device Manager menus.
  4. Open the "View" menu.
  5. If there is a to the left of the "Show hidden devices" menu item, click on "Show hidden devices" to disable it.
  6. Open the "Ports (COM & LPT)" section of the Device Manager tree.
  7. You should see a port identified as "USB-SERIAL CH340 (COMn)" under the "Ports (COM & LPT)" section (where "COMn" is some serial port e.g., COM4). Double click on that item.
    The "USB-SERIAL CH340 (COMn) Properties" dialog will open.
  8. Select the "Drivers" tab of the "USB-SERIAL CH340 (COMn) Properties" dialog.
  9. Select "Update driver" from the context menu.
    An "Update Drivers Device - USB-SERIAL CH340 (COMn)" dialog will open.
  10. Click on "Search automatically for drivers" in the "Update Drivers Device - USB-SERIAL CH340 (COMn)" dialog.
  11. You should now see the driver installation wizard update the driver. Wait for the update to finish, as indicated by the message "Windows has successfully updated your drivers" in the dialog.
    :exclamation: It is possible you will instead see the message "The best drivers are already installed". If so, please stop following the instructions here and reply on the forum thread to let me know. I'll provide alternative instructions you can follow.
  12. Click the "Close" button in the "Update Drivers Device - USB-SERIAL CH340 (COMn)" dialog.
  13. Click the "Roll Back Driver" button in the "USB-SERIAL CH340 (COMn) Properties" dialog.
    The "Driver Package rollback" dialog will open.
  14. Click the radio button next to "My apps don't work with this driver" in the "Driver Package rollback" dialog .
  15. Click the "Yes" button.
  16. Click the "Close" button in the "USB-SERIAL CH340 (COMn) Properties" dialog.

Now start Arduino IDE again and repeat whatever you were doing before when you encountered that error before. Hopefully this time you will not encounter that "can't set com-state" error during the sketch upload.