Controller by picklesandicecream
In this tutorial I shall explain how you can turn your Arduino chip into a HID keyboard device.
This is done by updating the Firmware on your chip with FLIP.
The cool thing about this trick is that you can make your own game controller or macro keyboard with the power of the Arduino coding method, so possibility are endless for great prototypes.
I have put all files into a Google Drive map for you to download.
link: https://drive.google.com/open?id=1jfOJmFf9C6QCb8I_...
I also have made a youtube Video for the coding part.
Arduino UNO or Mega
4 push buttons
4 resitors 1k ohm
Jumper cables
Video link: https://www.youtube.com/watch?v=j05vj8zRP1o
Write an end buffer method to send a bit when button is released, this step is required to end the data stream of the HID keyboard. For this example we send the key code through buf[2] so we need to reset them to 0 when the button on the Arduino is released. Note: Without this step you’re HID keyboard can start sending button inputs but it will never stop sending bits until the HID keyboard (Arduino) USB is unplugged.
uint8_t buf[8] = { 0 }; //Keyboard report buffer
#define PIN_W 4 // Pin for w
#define PIN_A 5 // Pin for a
#define PIN_S 6 // Pin for s
#define PIN_D 7 // Pin for d
void setup() {
Serial.begin(9600); // Setup Serial communication
//Set pinmode of Input pins
pinMode(PIN_W, INPUT);
pinMode(PIN_A, INPUT);
pinMode(PIN_S, INPUT);
pinMode(PIN_D, INPUT);
}
void loop() {
//When button representing W is pressed
if (digitalRead(PIN_W) == HIGH) {
buf[2] = 26; // W keycode
Serial.write(buf, 8); // Send keypress
releaseKey();
}
//When button representing A is pressed
if (digitalRead(PIN_A) == HIGH) { buf[2] = 4; // A keycode
Serial.write(buf, 8); // Send keypress
releaseKey();
}
//When button representing S is pressed
if (digitalRead(PIN_S) == HIGH) { buf[2] = 22; // S keycode
Serial.write(buf, 8); // Send keypress
releaseKey();
}
//When button representing D is pressed
if (digitalRead(PIN_D) == HIGH) { buf[2] = 7; // D keycode
Serial.write(buf, 8); // Send keypress
releaseKey();
}
}
// Function for Key Release
void releaseKey() {
buf[0] = 0;
buf[2] = 0;
Serial.write(buf, 8); // Send Release key
}
To install FLIP please install JRE - Flip Installer - 3.4.7.112.exe provided in the Google Drive link
Note: When starting up you get the error "AtLibUsbDfu.dll not found" you have to install a driver.
Here is a solution made by MDGrein link: https://www.youtube.com/watch?v=KQ9BjKjGnIc
short the 2 ICSP2 pins as shown in the image
To put the Arduino in the DFU (Device Firmware Update) mode, so that FLIP can access the Firmware
on the Arduino Chip. More info on this reference link: https://www.arduino.cc/en/Hacking/DFUProgramming8...
You can do that by repeating the steps after Step 12 Arduino into DFU mode,
only then chose Arduino-usbserial-uno.hex instead of arduino-keyboard.hex