microcontroller to use for usb keyboard interface

Discussion in 'General Electronics Chat' started by magnet18, Oct 5, 2013.

  1. magnet18

    Thread Starter Senior Member

    Dec 22, 2010
    1,232
    124
    So this is a bit of a hardware/software mashup question

    I recently got a neat $5 infrared keyboard from goodwill, and I'm trying to make a receiver for it.

    Right now I have an arduino UNO with an IR reciever, and I have this code to decode the signals-

    Code ( (Unknown Language)):
    1. #include <IRremote.h>
    2.  
    3. int RECV_PIN = 11;
    4. IRrecv irrecv(RECV_PIN);
    5. decode_results results;
    6.  
    7. double previous = 0;
    8. double end_one = 4146893829;
    9. //double end_two = NEED_OUTPUT_VALUE;
    10. double output = 0;
    11.  
    12. void setup()
    13. {
    14.   Serial.begin(9600);
    15.   irrecv.enableIRIn(); // Start the receiver
    16. }
    17.  
    18. void loop() {
    19.   if (irrecv.decode(&results)) {
    20.     if (results.value == end_one) {
    21.       Serial.println("end_all");
    22.     }else if(results.value != previous){  //if it is a useful value
    23.       Serial.println(results.value);
    24.       //output = findChar(results.value);
    25.       previous = results.value;
    26.     }
    27.     irrecv.resume(); // Receive the next value
    28.   }
    29. }
    30.  
    31. double findChar() {
    32.   double code = results.value;
    33.  
    34.   //NEED CODE TO FIND CHARACTER/COMMAND DATA FROM VALUE
    35.   //POSSIBLY MAKE AN ARRAY OF CODES, WITH THE ELEMENT CORRESPONDING TO THE ASCII VALUE
    36.   if(results.value /*within bounds of ascii characters*/) {
    37.     //return value of ascii character
    38.     //or code for keyboard command
    39.     //or execute keyboard command from here
    40.   }else if(results.value /*volume or other such command key*/) {
    41.     //return command information, or do command, or something
    42.   }else if(results.value /*shift key or function key or other such key, need to look at keyboard protocol for a standard usb keyboard*/) {
    43.     //need to look at keyboard protocol
    44.   }
    45.   return(0/*WHATERVERINEEDTORETURN*/);  //!!!!!!!!!!!!
    46. }
    47.  
    this is using this library.

    it successfully decodes things into values (hex or dec or whatever I choose), which I need to correlate to specific keys

    it seems that each key has a "Key Down" value that is transmitted when a key is pressed, and a different "KEY Up" value, transmitted when a key is release, and then when all keys have been released the keyboard transmits another code, i would assume to communicate that no keys are being pressed anymore

    my question for the more experienced is this,
    what microcontroller should i use for going forward, as I would like to build a simple pcb with the microcontroller on it to just plug into a USB port

    I have heard varying stories of arduinos versus other uC's being able to communicate using USB keyboard protocols , and was wondering if anyone had any advice

    Thanks!!
     
Loading...