microcontroller to use for usb keyboard interface

Thread Starter

magnet18

Joined Dec 22, 2010
1,227
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-

Rich (BB code):
#include <IRremote.h>

int RECV_PIN = 11;
IRrecv irrecv(RECV_PIN);
decode_results results;

double previous = 0;
double end_one = 4146893829;
//double end_two = NEED_OUTPUT_VALUE;
double output = 0;

void setup()
{
  Serial.begin(9600);
  irrecv.enableIRIn(); // Start the receiver
}

void loop() {
  if (irrecv.decode(&results)) {
    if (results.value == end_one) {
      Serial.println("end_all");
    }else if(results.value != previous){  //if it is a useful value
      Serial.println(results.value);
      //output = findChar(results.value);
      previous = results.value;
    }
    irrecv.resume(); // Receive the next value
  }
}

double findChar() {
  double code = results.value;
  
  //NEED CODE TO FIND CHARACTER/COMMAND DATA FROM VALUE
  //POSSIBLY MAKE AN ARRAY OF CODES, WITH THE ELEMENT CORRESPONDING TO THE ASCII VALUE
  if(results.value /*within bounds of ascii characters*/) {
    //return value of ascii character
    //or code for keyboard command
    //or execute keyboard command from here
  }else if(results.value /*volume or other such command key*/) {
    //return command information, or do command, or something
  }else if(results.value /*shift key or function key or other such key, need to look at keyboard protocol for a standard usb keyboard*/) {
    //need to look at keyboard protocol
  }
  return(0/*WHATERVERINEEDTORETURN*/);  //!!!!!!!!!!!! 
}
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!!
 
Top