SF Pro Micro Golf SIM controller

I need some assistance, I have a sparkfun pro micro that I am trying to use to control keyboard shortcuts while playing a golf simulator. The pro micro will type out the correct shortcuts in Notepad, but while the game is going it doesn't seem to register the buttons when they are pressed. I'm unsure if this is a setting inside windows, the game itself, or my programming?
Any ideas would be greatly appreciated.
On a side note, I have a wireless USB keyboard that does work, so it makes believe its something in the pro micro not windows.

simphoto.jpg

simphoto.jpg

Do You think posting that "something in the pro micro" would have a point?

Do you think it might help if you posted your code and a schematic of your hardware ?

Please follow the advice on posting code given in posting code

In particular note the advice to Auto format code in the IDE and to use code tags when posting code here as it prevents some combinations of characters in code being interpreted as HTML commands such as italics, bold or a smiley character, all of which render the code useless

This is my first try at using anything arduino based and doing any type of programming. I've searched through many post to try and find the correct code for what I am trying to accomplish.
Each pin 2-10,16 are wired to momentary switches, the other side of the switch is grounded.
It works correctly in Notepad, as far as typing the correct characters and moving the cursor around as it should. But once in the program (Optishot 2) none of the buttons respond. But pushing the same keys on keyboard does work.
Any help would be appreciated, its a little bit of a steep curve just getting started.

#include <Keyboard.h>    // This is a "built-in" library no need to install
//---------------------------------------------------------
//                           Setup
//---------------------------------------------------------



void setup() {
pinMode(2,INPUT_PULLUP);  // sets pin 2 to input & pulls it high w/ internal resistor
pinMode(3,INPUT_PULLUP);  // sets pin 3 to input & pulls it high w/ internal resistor
pinMode(4,INPUT_PULLUP);  // sets pin 4 to input & pulls it high w/ internal resistor
pinMode(5,INPUT_PULLUP);  // sets pin 5 to input & pulls it high w/ internal resistor
pinMode(6,INPUT_PULLUP);  // sets pin 6 to input & pulls it high w/ internal resistor
pinMode(7,INPUT_PULLUP);  // sets pin 7 to input & pulls it high w/ internal resistor
pinMode(8,INPUT_PULLUP);  // sets pin 8 to input & pulls it high w/ internal resistor
pinMode(9,INPUT_PULLUP);  // sets pin 9 to input & pulls it high w/ internal resistor
pinMode(10,INPUT_PULLUP);  // sets pin 10 to input & pulls it high w/ internal resistor
pinMode(16,INPUT_PULLUP);  // sets pin 16 to input & pulls it high w/ internal resistor

Serial.begin(9600);       // begin serial comms for debugging
Keyboard.begin();         //begin Keyboard

}

//---------------------------------------------------------
//                           Loop
//---------------------------------------------------------

void loop() {
  
 

 if (digitalRead(2) == 0)  // if buton 2 is pushed
  {
    Keyboard.write('F');  // send single character "F"
    delay(1000);           // delay so you don't get 20 F's
  }
  if (digitalRead(3) == 0)  // if button 3 is pressed
  {
    Keyboard.write('S');  // send single character "S"
    delay(1000);           // delay so you don't get 20 S's
  }
  if (digitalRead(4) == 0)  // if button 4 is pressed
  {
    Keyboard.write('M');  // send single character "M"
    delay(1000);           // delay so you don't get 20 M's
  }
  if (digitalRead(5) == 0)  // if button 5 is pressed
  {
    Keyboard.write('C');  // send single character "C"
    delay(1000);           // delay so you don't get 20 C's
  }
  if (digitalRead(6) == 0)  // if button 6 is pressed
  {
    Keyboard.press(0xDA);   //keyboard up arrow
    Keyboard.releaseAll();
    delay(600);
  }
if (digitalRead(7) == 0)  // if button 7 is pressed
  {
    Keyboard.press(0xD9);   //keyboard down arrow
    Keyboard.releaseAll();   
     delay(600);
  }
if (digitalRead(8) == 0)  // if button 8 is pressed
  {
    Keyboard.press(0xD8);   //keyboard left arrow
    Keyboard.releaseAll();   
    delay(600);
  }
if (digitalRead(9) == 0)  // if button 9 is pressed
  {
    Keyboard.press(0xD7);   //keyboard right arrow
    Keyboard.releaseAll();   
    delay(600);
  }
if (digitalRead(10) == 0)  // if button 10 is pressed
  {
    Keyboard.press(0x80);   //keyboard ctrl key 
    Keyboard.press(0xDA);   // keyboard up arrow
    Keyboard.releaseAll();   
    delay(600);
  }
if (digitalRead(16) == 0)  // if button 16 is pressed
  {
    Keyboard.press(0x80);   //keyboard ctrl key 
    Keyboard.press(0xD9);   // keyboard down arrow
    Keyboard.releaseAll(); 
    delay(600);
  }

  Keyboard.end();                 //stops keyboard
}

Why does loop() end with

  Keyboard.end();                 //stops keyboard

?

How will the next turn in loop() work then?

Honestly I’m unsure. I found this code sample online and made changes to it for what I needed it to do, or at least what I thought it needed. Lots of trial and error. I’ll try removing it and see what effect it has.

Railroader:
Why does loop() end with

  Keyboard.end();                 //stops keyboard

?

How will the next turn in loop() work then?

I removed keyboard.end , does not seem to have any effect either way. Have any other ideas?

The keys pressed reaches Notepad ok. Then I can only say that there is an issue in the Pc as the receiving task doesn't do what Notepad is doing. By that we are beyond my ideas but surly there are helpers knowing more. Wait a little and have faith.

Railroader:
The keys pressed reaches Notepad ok. Then I can only say that there is an issue in the Pc as the receiving task doesn't do what Notepad is doing. By that we are beyond my ideas but surly there are helpers knowing more. Wait a little and have faith.

Ok, Thank You.

Anyone have a suggestion?

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.