on an ardunio, is there a way to detect if a data connection (vs power only) is present? I want to have my arduino behave differently if connected to a pc, or on stand alone power.

specifically, I have a project that sends keystrokes to a midi piano program I wrote, but when a pc is not connected, I would like to have the arduino send the notes to a peizo buzzer attached to the circuit instead. Im using a teensy, or a leonardo, or an Uno.

  • You could have the main code run when a signal is sent over the serial monitor... – Levi Lesches Aug 7 '19 at 22:56
  • 1
    Teensy and Leonardo, probably yes. Uno - no. – Majenko Aug 7 '19 at 23:02
  • for sending keystrokes, no on the uno, but I still think it may be possible to get a status indication. useful for other projects. does the arduino look at the rx/tx pins of the usb? – j0h Aug 8 '19 at 0:46
  • 1
    Are you using the Keyboard class to send HID reports, or are you using Serial and then your program is interpreting it as key presses? – Majenko Aug 8 '19 at 9:43
  • In this project I am using the keyboard class. I was thinking the arduino would have a data pin I could monitor. – j0h Aug 8 '19 at 20:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.