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! ![]()