Go Down

Topic: Keyborad connected to native USB port, no power from the USB port for the keyboa (Read 705 times) previous topic - next topic

conradelektro

My Arduino Due is connected to the PC via its programming USB port and I use the Serial Monitor to communicate with the Arduino Due via its programming USB port.

I connected a keyboard to the native USB port of my Arduino Due.

First question: The keyboard gets no power from the native USB port of the Arduino Due. Is this normal? Is there no power on the native USB baord for a Keyboard or a Mouse?

Second Qustion: I wrote the following sketch to test a keyboard on the native USB port, is it correct?

/*
Keyboard Controller

Shows the output of a USB Keyboard connected to the USB
controller of an Arduino Due Board.
*/

#include <KeyboardController.h>

char inByte = 0;                 // incoming serial byte
// Initialize USB Controller
USBHost usb;

// Attach Keyboard controller to USB
KeyboardController keyboard(usb);

void setup(){
  Serial.begin(9600);
  establishContact();  // establish contact until receiver responds

}

void loop(){
 
  if (Serial.available() > 0) {
    inByte = Serial.read();
    Serial.print("vom PC : ");
    Serial.println(inByte);
  }
  usb.Task();
}

void keyPressed() {
  Serial.print("Pressed:  ");
  Serial.print(keyboard.getKey());
  Serial.println();
}

void establishContact() {
  while (Serial.available() <= 0) {
    Serial.println("Waits for connection to PC");   // send an initial string
    delay(1000);
  }
}

Greetings, Conrad

conradelektro

Very strange:

The keyboard gets power (and the sketch from my first post works) as long as the Arduino Due is not connected to an external power supply.

The moment I connect the Arduino Due to an external power supply both USB ports are disconnected from 5V, therefore also the native USB port does not provide power.

According to the schematics of the Arduino Due only the programming USB port should be disconnected from 5V when an external power supply is connected, the native USB port should always stay connected to 5V. But the schematics I have are probably wrong because the 5V at the native USB port would cause trouble when the native USB port is connected to a PC (which would provide power).

Greetings, Conrad

P.S.: Would be grateful for a clarification if and when the 5V are switched to the USB ports, specially to the native USB port.

Go Up