mirror of
https://github.com/felis/USB_Host_Shield_2.0.git
synced 2024-03-22 11:31:26 +01:00
Print when connected and disconnected from accessory
This commit is contained in:
parent
655b60ea90
commit
843eec8ba6
1 changed files with 13 additions and 2 deletions
|
@ -13,6 +13,7 @@ ADK adk(&Usb, "TKJElectronics", // Manufacturer Name
|
||||||
#define LED LED_BUILTIN // Use built in LED - note that pin 13 is occupied by the SCK pin on a normal Arduino (Uno, Duemilanove etc.), so use a different pin
|
#define LED LED_BUILTIN // Use built in LED - note that pin 13 is occupied by the SCK pin on a normal Arduino (Uno, Duemilanove etc.), so use a different pin
|
||||||
|
|
||||||
uint32_t timer;
|
uint32_t timer;
|
||||||
|
boolean connected;
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
|
@ -27,7 +28,13 @@ void setup() {
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
Usb.Task();
|
Usb.Task();
|
||||||
|
|
||||||
if (adk.isReady()) {
|
if (adk.isReady()) {
|
||||||
|
if (!connected) {
|
||||||
|
connected = true;
|
||||||
|
Serial.print(F("\r\nConnected to accessory"));
|
||||||
|
}
|
||||||
|
|
||||||
uint8_t msg[1];
|
uint8_t msg[1];
|
||||||
uint16_t len = sizeof(msg);
|
uint16_t len = sizeof(msg);
|
||||||
uint8_t rcode = adk.RcvData(&len, msg);
|
uint8_t rcode = adk.RcvData(&len, msg);
|
||||||
|
@ -51,7 +58,11 @@ void loop() {
|
||||||
Serial.print(timer);
|
Serial.print(timer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
if (connected) {
|
||||||
|
connected = false;
|
||||||
|
Serial.print(F("\r\nDisconnected from accessory"));
|
||||||
digitalWrite(LED, LOW);
|
digitalWrite(LED, LOW);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue