Skip to content

Commit 2a8759c

Browse files
committed
[GIGA] USB Keyboard Example fix
Updated example that was broken.
1 parent bf9740c commit 2a8759c

File tree

1 file changed

+17
-8
lines changed
  • content/hardware/10.mega/boards/giga-r1-wifi/tutorials/giga-usb

1 file changed

+17
-8
lines changed

content/hardware/10.mega/boards/giga-r1-wifi/tutorials/giga-usb/giga-usb.md

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -432,34 +432,43 @@ After logging data, remove the USB stick from your board, and insert it in your
432432

433433
It is possible to connect generic USB keyboards to the GIGA R1's USB-A connector without any additional circuitry.
434434

435-
The library used for this can be downloaded through Github.
435+
The library used for this can be downloaded through Github.
436436
- [USBHostGiga](https://github.com/arduino-libraries/USBHostGiga)
437437

438+
Please note that this library is in **Alpha** development stage. This means support is experimental and examples may not function as expected. Future versions of this library may break the example provided below.
439+
438440
***The USBHostGiga library is not available in the Arduino IDE and needs to be installed manually. You can do so my navigating to `Sketch` > `Include Library` > `Add .ZIP Library`.***
439441

440442
```arduino
441-
#include "HIDHost.h"
443+
#include "USBHostGiga.h"
442444
443-
Keyboard keyb; //create object
445+
//REDIRECT_STDOUT_TO(Serial)
446+
Keyboard keyb;
447+
HostSerial ser;
444448
445449
void setup() {
446450
// put your setup code here, to run once:
447451
Serial.begin(115200);
448452
while (!Serial);
449-
pinMode(PA_15, OUTPUT); //enable the USB-A port //enable the USB-A connector
450-
keyb.begin(); //init the library
453+
pinMode(PA_15, OUTPUT);
454+
keyb.begin();
455+
ser.begin();
451456
}
452457
453458
454459
void loop() {
455460
if (keyb.available()) {
456-
Serial.println(keyb.read()); //print any incoming character
461+
auto _key = keyb.read();
462+
Serial.println(keyb.getAscii(_key));
463+
}
464+
while (ser.available()) {
465+
auto _char = ser.read();
466+
Serial.write(_char);
457467
}
468+
//delay(1);
458469
}
459470
```
460471

461-
***Please note that he `PA15` pin must be configured as an `OUTPUT`.***
462-
463472
## USB HID
464473

465474
It is possible to turn your GIGA R1 board into a Human Interface Device **(HID)**, aka mouse & keyboard, using the [USBHID](https://github.com/arduino/ArduinoCore-mbed/tree/master/libraries/USBHID) library which is included in the GIGA core.

0 commit comments

Comments
 (0)