I’m creating a button box for a space simulator, how I plan to make is to use an Arduino Mega for the buttons and then send the data via serial to a Pro Micro that will convert it to keypresses. The data will be numbers equal to the ASCII character vaules parsed from the serial data. How do I use the numbers with the keyboard.press function? The reason that I am using that function is because I need to send modifier keys as well as alphanumeric characters any advice or knowledge of any sort would be welcome
Just pass the number parsed from serial to the Keyboard.press() function. You can pass any integer type to the function (a char is just another integer type), the compiler will convert it to the correct data type for you.
int buttonCode = Serial.parseInt(); // do some error checks here, is buttonCode in the expected range? Keyboard.press(buttonCode);