Beginner problem with keyboard code

Hi, I have searched on google and in the forum for a couple of hours now, and I can't seem to find anything that solves my problem. (atleast anything I understand)

I have just started using ARDUINO. So this is my first attempt at C++ Coding. I am pretty good at electronics, but I have never used codes except for macros in Excel.

What Im trying to do:
I want to make a "log point" button for a GPS in an excavator. It is basically really simple. I need a button that does the same as if I connect a USB keyboard to the GPS screen. It only need to Press "F7" and wait half a second and then press "Enter" or "ESC"

I use the ANDRUINO Pro Mini board, and is is all wired up with button and USB cable (USB to GPS Screen). I believe it should work!

My problem is the coding. to make it short:
My code needs to "tell" the GPS it is a USB keyboard and then press F7 followed by Enter or ESC

My Code so far:

// Require keyboard control library
#include <KeyboardController.h>
#include "Arduino.h"

// Initialize USB Controller
USBHost usb;

// Attach keyboard controller to USB
KeyboardController keyboard(usb);

// This function intercepts key press
void keyPressed() {
  Serial.print("Pressed: KEY_F7 ");
  delay(1000);
  Serial.print("Pressed: KEY_ESC ");
  printKey();
}

// This function intercepts key release
void keyReleased() {
  Serial.print("Released: ");
  printKey();
}

void printKey() {
  // getOemKey() returns the OEM-code associated with the key
  Serial.print(" key:");
  Serial.print(keyboard.getOemKey());

  // getModifiers() returns a bits field with the modifiers-keys
  int mod = keyboard.getModifiers();
  Serial.print(" mod:");
  Serial.print(mod);

  Serial.print(" => ");

  if (mod & LeftCtrl)
    Serial.print("L-Ctrl ");
  if (mod & LeftShift)
    Serial.print("L-Shift ");
  if (mod & Alt)
    Serial.print("Alt ");
  if (mod & LeftCmd)
    Serial.print("L-Cmd ");
  if (mod & RightCtrl)
    Serial.print("R-Ctrl ");
  if (mod & RightShift)
    Serial.print("R-Shift ");
  if (mod & AltGr)
    Serial.print("AltGr ");
  if (mod & RightCmd)
    Serial.print("R-Cmd ");

  // getKey() returns the ASCII translation of OEM key
  // combined with modifiers.
  Serial.write(keyboard.getKey());
  Serial.println();
}

void setup()

{
  Serial.begin(9600);
  Serial.println("Program started");
  delay(200);
}

void loop()
{
  // Process USB tasks
  usb.Task();
}

I have just copied one of the exaples in the Arduino 1.5.6-r2 BETA program and filled in what I atleast think I should do.
I leave the sentences with // in place just so I can get a better understanding of what the different codes do!

When i try to verify it i get the error message: Compiling error (or something similar since I get in it Norwegian)

Copy of error message:

Arduino:1.5.6-r2 (Windows 7), Kort"Arduino Pro or Pro Mini, ATmega328 (5V, 16 MHz)"

WARNING: library USBHost claims to run on [sam] architecture(s) and may be incompatible with your current board which runs on [avr] architecture(s).



In file included from C:\Program Files (x86)\Arduino\libraries\USBHost\src/KeyboardController.h:22,
                 from sketch_may14a.ino:2:
C:\Program Files (x86)\Arduino\libraries\USBHost\src/hidboot.h: In member function 'virtual void HIDBoot<BOOT_PROTOCOL>::EndpointXtract(uint32_t, uint32_t, uint32_t, uint32_t, const USB_ENDPOINT_DESCRIPTOR*)':
C:\Program Files (x86)\Arduino\libraries\USBHost\src/hidboot.h:474: error: 'UOTGHS_HSTPIPCFG_PTYPE_INTRPT' was not declared in this scope
C:\Program Files (x86)\Arduino\libraries\USBHost\src/hidboot.h:474: error: 'UOTGHS_HSTPIPCFG_PTOKEN_IN' was not declared in this scope
C:\Program Files (x86)\Arduino\libraries\USBHost\src/hidboot.h:474: error: 'UOTGHS_HSTPIPCFG_PBK_1_BANK' was not declared in this scope
C:\Program Files (x86)\Arduino\libraries\USBHost\src/hidboot.h:474: error: there are no arguments to 'UHD_Pipe_Alloc' that depend on a template parameter, so a declaration of 'UHD_Pipe_Alloc' must be available
C:\Program Files (x86)\Arduino\libraries\USBHost\src/hidboot.h:474: error: (if you use '-fpermissive', G++ will accept your code, but allowing the use of an undeclared name is deprecated)
C:\Program Files (x86)\Arduino\libraries\USBHost\src/hidboot.h: In member function 'virtual uint32_t HIDBoot<BOOT_PROTOCOL>::Release()':
C:\Program Files (x86)\Arduino\libraries\USBHost\src/hidboot.h:500: error: there are no arguments to 'UHD_Pipe_Free' that depend on a template parameter, so a declaration of 'UHD_Pipe_Free' must be available
C:\Program Files (x86)\Arduino\libraries\USBHost\src/hidboot.h: In member function 'uint32_t HIDBoot<BOOT_PROTOCOL>::Release() [with unsigned char BOOT_PROTOCOL = 1u]':
sketch_may14a.ino:72:   instantiated from here
C:\Program Files (x86)\Arduino\libraries\USBHost\src/hidboot.h:500: error: 'UHD_Pipe_Free' was not declared in this scope
C:\Program Files (x86)\Arduino\libraries\USBHost\src/hidboot.h: In member function 'void HIDBoot<BOOT_PROTOCOL>::EndpointXtract(uint32_t, uint32_t, uint32_t, uint32_t, const USB_ENDPOINT_DESCRIPTOR*) [with unsigned char BOOT_PROTOCOL = 1u]':
sketch_may14a.ino:72:   instantiated from here
C:\Program Files (x86)\Arduino\libraries\USBHost\src/hidboot.h:474: error: 'UHD_Pipe_Alloc' was not declared in this scope

  Denne rapporten vil inkludere mer informasjon med
  "Vis detaljert informasjon under kompilering"
  enabled in File > Preferences.

And remember I am completely new to C++ coding, so I guess Ill have to check half the words/expressions you guys use up in a dictionary!

Any help will be apreciated! :slight_smile:

WARNING: library USBHost claims to run on [sam] architecture(s) and may be incompatible with your current board which runs on [avr] architecture(s).

The Pro Mini uses a ATmega328 which has no USB...

That library appears to be designed for the Due?

there is no micro USB port on the Pro Mini card, but I have soldered a USB cable to the outputs I want to use. (Very likely I have missed completely on the code!)

I was pretty sure it was possible to get it to work this way. But should I use another "example" to build my code upon?

How the wiring is done/supposed to be done:
USB Cable: Arduino card:
Red 5V
Green D3
White D2
Black GND

Pulse switch: Arduino card:
Black D4
Red 5V

123? restisance: Arduino:
1 D4
2 GND

The resistance I got told to put in there to avoid the "input" to be high after releasing the button.

Very likely I have missed completely on the code!)

No, you've missed something on the hardware. The Arduino you have is not capable of announcing itself as a keyboard. Get a Leonardo or a Micro, which can, or a Teensy which is probably better for your purposes (it really is teensy).