You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
AE-577: Added basic comments to example sketches to explain their intended purpose; Implemented in "KeyboardAndMouse" sketch the same solution to print mouse data to console, as used in the "Mouse" example.
Copy file name to clipboardExpand all lines: examples/Keyboard/Keyboard.ino
+5-2Lines changed: 5 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -1,3 +1,5 @@
1
+
/* This simple example shows how to read keyboard data by both listening for events and polling for available character data in the internal buffers of the USB HID Host */
2
+
1
3
#include<Arduino.h>
2
4
#include<Arduino_USBHIDHost.h>
3
5
@@ -17,15 +19,16 @@ void setup() {
17
19
while (!Serial);
18
20
19
21
kb.attachConnectionCallback(onKeyboardConnected);
20
-
kb.attachKeyboardEventCallback(onKeyboardEvent);
22
+
kb.attachKeyboardEventCallback(onKeyboardEvent);// Register callback to get the keystrokes via events
21
23
kb.begin();
22
24
}
23
25
24
26
voidloop() {
25
27
kb.poll();
26
28
29
+
// Second way of reading back the keystrokes is via polling for available characters
Copy file name to clipboardExpand all lines: examples/KeyboardAndMouse/KeyboardAndMouse.ino
+27-16Lines changed: 27 additions & 16 deletions
Original file line number
Diff line number
Diff line change
@@ -1,10 +1,24 @@
1
+
/* This simple example demonstrates how to read mouse and keyboard data, by connecting these devices at the same time to the Portenta, via a USB hub */
2
+
1
3
#include<Arduino.h>
2
4
#include<Arduino_USBHIDHost.h>
3
5
6
+
/*
7
+
* In order to use two (or more) HID devices connected via a USB hub to your Portenta C33 board, please open "tusb_config.h" below (right click -> Go To Definition)
8
+
* and make sure that "CFG_TUH_HUB" is set to value 1, and that "CFG_TUH_HID" is set to the number of HID devices you intend to connect to your Arduino (2 in this example).
9
+
* Please also keep in mind that some keyboards and mice which include advanced illumination features might draw more power than the Arduino is able to provide on its
10
+
* USB-A port and might therefore lead to a reset or failure to be enumerated by the board. Ideally, use basic USB keyboards and mice, these should work best.
0 commit comments