# Find address for keys F1-F6



## dannysampson (Mar 3, 2014)

Hello all,

im danny and new to this site. Im currently studying at college and creating a project for my hobby, Amateur radio, but for a college project they want me to create a program to controll the motors for the antenna. The motor will be controlled by Keys on the Keyboard specifically F1 - F6. I will somehow need to follow the keys internally for find what bits they are. Then map these bits to a USB connection for my controller. I am not that computer literature so am struggling a little. Any help would be greately appreciated. ( laptop in question is a sony vaio curring running windows 7)

Thank you 
Daniel


----------



## gcavan (Aug 13, 2009)

Probably easier to use readymade software such as AutoHotkey to do that part of the work for you.


----------



## Fjandr (Sep 26, 2012)

If you're coding it in C, here's an implementation of a USB keyboard:

C code for Teensy: USB Keyboard


----------



## dannysampson (Mar 3, 2014)

Its not a usb keyboard, but i want the keys of the laptop keyboard to controll an external motor (not directly) but for e.g. press F1 and the motor will move up ect ect. This information then needs to be transfered through usb port on my laptop to my device. 
Sorry if im not very clear.


----------



## gcavan (Aug 13, 2009)

Use AutoHotKey to remap the keys to trigger a custom macro.


----------



## Fjandr (Sep 26, 2012)

Ah, gotcha. So, laptop > USB > micro-controller > stepper motor.

I can't help with code examples, but you'll need to use one of the USB HID APIs to send the scan codes via USB to your external controller. It's entirely likely that you can find examples where someone is outputting scan codes via USB to an Arduino. Such a program would already be doing what you want, so all you'd need to do is lift the code which creates an output hook to USB and drop that into your control program.

Working with USB HIDs

All the scan code info you could ever want:
Altek Instruments -> BarcodeMan -> Keyboard Scan Codes

AutoHotkey won't help in this situation, as it only sends scan codes to the host machine. It has no capability to output those codes to an external, USB-attached device.


----------



## dannysampson (Mar 3, 2014)

Yes thats exactly it FJandr hit the nail on the head. Ok all sounds a little techno blabble to me so will have to do some research on this subject. This sounds extremely complicated.


----------



## dannysampson (Mar 3, 2014)

I am struggling to find any software that can transfere scancodes through USB. Can anyone help with this?
thanks.


----------



## Fjandr (Sep 26, 2012)

It's unlikely you'll find anything that doesn't need at least some modification. I'll look around tomorrow and see if I can't find anyone working on an Arduino project that requires sending output to USB.


----------



## Fjandr (Sep 26, 2012)

It's been pointed out to me that I missed the "college project" part of the OP. I read it as you were doing this as a hobby project. What part of this, exactly, is the "college" part? We can't help you much with completing assignments for school.


----------



## dannysampson (Mar 3, 2014)

Its not a school project, what it is, is that i have to treat this as a project and manage this, as a project, from design concept to implimentation to market research. The assignment is not on the product its on my ability to oversee the whole project keeping targets and writing reports.


----------



## Fjandr (Sep 26, 2012)

Ah, then this would actually fit as part of the research process for the project. As a result, the content help for the research _shouldn't_ violate the forum rules (in my opinion, anyway). I'll check to make sure there's agreement on that with the other admins and moderators


----------



## Fjandr (Sep 26, 2012)

Sounds like we're good to go on continuing with the research help since that's not actually what you're being graded directly on.

After doing a bit of research, it appears most PC-to-Arduino communications libraries use a serial link over USB. Most projects seem to be interested in sending USB keyboard emulation data from the Arduino to the PC, while what you want to accomplish is the exact opposite.

Here's a basic tutorial on two-way serial communication between an Arduino and a PC. You should be able to use it to send scan codes to the Arduino, and then pipe the return Arduino output to the motor controller. It should be a place to start, and it doesn't require a USB shield for the Arduino to operate.


----------



## dannysampson (Mar 3, 2014)

Hi yes i have my board now and going to try a LCD display if i get time, I also have the USB to seriel lead aswell. Ok then thank you and i will continue my research. Thank you for the help. I have looked through your website and think i have been able to find the scan codes for the relevant keys.


----------



## Fjandr (Sep 26, 2012)

Good deal.

I haven't actually done any Arduino programming myself, so I probably can't be much more help in that regard, but I am pretty good at finding appropriate resources. If you find yourself stuck, feel free to hit the forum up for more help.


----------



## dannysampson (Mar 3, 2014)

I can do the programming this isnt a problem, it is just getting the keys to give an input through usb to the arduino. Thats the part im struggling on at the moment...


----------

