USB keyboard with two potentiometers

I'm trying to make a USB keyboard(arrow-up, down, left, right) input with two potentiometers.
So, when i connect the output of the board into the USB port of the laptop, i can play the game with the pots.
The problem is i can't find any code about this project.

https://www.arduino.cc/en/Tutorial/JoyStick

I tried to use this code but i didn't really work.
It's probably i don't have that actual joystick.

Currently, i'm only using two 10k potentiometer.

Please help me.

kongithekong:
I'm trying to make a USB keyboard(arrow-up, down, left, right) input with two potentiometers.
So, when i connect the output of the board into the USB port of the laptop, i can play the game with the pots.
The problem is i can't find any code about this project.

https://www.arduino.cc/en/Tutorial/JoyStick

I tried to use this code but i didn't really work.
It's probably i don't have that actual joystick.

Currently, i'm only using two 10k potentiometer.

Please help me.

Quite a complex project for someone new to Arduino. A real USB keyboard sends keystroke codes to the computer when a key is pressed and a different code when it is released. How do you intend for potentiometers to relate to keypress codes?

Then the Arduino communication with the laptop is via serial communication. Your project might be doable if you wrote a PC program to receive the serial stream of data and convert that to make the PC think it's getting keystroke data.

Paul

This can be done with a Leonardo or Micro which can act as a USB keyboard/mouse and is absolutely doable.

But you need to understand the basics and write non-blocking code.

See this thread for useful tips: Useful links - check here for reference posts / tutorials
And especially this: How to do several things at a time

Start with the joystick example and modify it to calculate a "repeat rate" for up/down/left/right depending on the joystick's position.

For testing, use Serial monitor and print ie U/D/L/R at the desired rate.

Look at the built in Keyboard examples in the IDE. Built in examples - USB
Make a simple sketch using the Keyboard-library and get familiar with sending keystrokes.

Implement the keyboard-routines to your joystick sketch.

Be aware that a badly working "keyboard" might flood your PC with keypresses, making it difficult, or even impossible, to use.....