Added HelloWorld example

This commit is contained in:
Nico 2015-01-11 23:10:14 +01:00
parent 43300a65db
commit cc8940b9ec
3 changed files with 41 additions and 3 deletions

View file

@ -87,15 +87,19 @@ Same for Micro and HoodLoader2. Not all HID reports are playing well together on
With the custom report you can try it out yourself. Everything you need should be in the pins_arduino.h file.
##### 3. Try the Basic HID examples for each HID device.
They are pretty much self explaining.
You can also see the *Projects/HID_Test* for an all in one example.
![example Picture](pictures/example.png)
You may want to start with the HelloWorld and HID_Basic examples. They are pretty much self explaining.
Ensure that always the correct HID-Core is selected.
See *Project/USB-Serial* for a fully usable USB-Serial bridge and how to use the new Serial functions.
In the CDC.h you can also see the new Control Line functions for advanced users.
Keep in mind that the USB_ENDPOINTs for the u2 Series are set to 16 bytes, so the Serial buffer is also smaller (normally 64b).
##### 4. Deactivate USB-Core to save flash and ram (optional)
If you don't want to use the USB-Core you can also choose under *Tools/USB Core* "No USB functions" to get rid of the USB stuff and save the ram for other stuff if you don't need it. You also don't need the HID Project essentially if you don't want to use the USB functions.
If you don't want to use the USB-Core you can also choose under *Tools/USB Core* "No USB functions" to get rid of the USB stuff
and save the ram for other stuff if you don't need it. You also don't need the HID Project essentially if you don't want to use the USB functions.
Due to a bad Leonardo/Micro bootloader you need to add an add an ISR into every sketch as workaround.
**This is not needed for HoodLoader2 devices**, since the bootloader does a true watchdog reset on reprogramming and not a simple application jump

View file

@ -0,0 +1,34 @@
/*
Copyright (c) 2014 NicoHood
See the readme for credit to other people.
Hello World Keyboard Beginner example
Press a button to write some text to your pc.
See official and HID Project documentation for more information.
*/
const int pinLed = LED_BUILTIN;
const int pinButton = 2;
void setup() {
// hardware setup
pinMode(pinLed, OUTPUT);
pinMode(pinButton, INPUT_PULLUP);
// Sends a clean report to the host. This is important on any Arduino type.
Keyboard.begin();
}
void loop() {
if (digitalRead(pinButton) == LOW) {
digitalWrite(pinLed, HIGH);
// Same use as the official library, pretty much self explaining
Keyboard.println("Hello World");
// simple debounce
delay(500);
digitalWrite(pinLed, LOW);
}
}

BIN
pictures/example.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB