Arduino Encoder steering Wheel

Hello everybody! For some time I have started a project: it consists in connecting a 6000 pulsation rotary encoder (industrial) to the mega 2560 board of arduino; thanks to the code I was able to put in a variable and print the rotation value in the serial monitor. My goal now is to make Windows recognize my arduino mega as a joystick and that my encoder variable is the x axis of that joystick; this step I have no idea how it can be done. Can anyone help me? Thank you

If you have no other idea - then the "idea" is: use is googling
https://www.google.de/search?as_q=arduino+mega+2560+usb+joystick
best regards Stefan

The Mega is a poor choice for a joystick, because the USB can not be programmed directly for that. Other boards such as Leonardo, Pro Micro have a processor that can easily be set up to be recognized by a PC as a pointing device.

I searched the internet but I didn't find anything

But these connections can also be made on arduino leonardo or missing pins (leave out the pins for the lcd that I do not need)? Thank you

keywords: arduino mega 2560 usb joystick

hits

still true:
I assume you have taken the Ardiuno Mega 2560 because he has so much direct IO-pins.
There are I2C-Io-expanders and ISP-Bus-IO-expanders that can extend the IO-pins to 64 or more if you like.

So a microcontroller that can act as a "native" USB-device will be a better choice
With IO.expanders that all run on a two wire I2C-Bus still something small like a seeeduino XIAO will be sufficient

I2C-IO-expander. You can have four such IOexpanders all running on the same two wire I2C-Bus

Seeeduino XIAO


best regards Stefan

Could you give a link to your rotary encoder ? I don't understand why both 'A' and '/A' are connected to a interrupt pin.
I think this is about such a rotary encoder: http://www.hessmer.org/blog/2011/01/30/quadrature-encoder-too-fast-for-arduino-with-solution/. The 6000 rpm is too fast for normal Arduino code. It uses only two interrupts.

Can you tell what is connected to the other pins ?
The display could be a I2C LCD display, then it uses only two pins.

There are a number of boards that support the Joystick. For example the Leonardo, the (Pro) Micro, some MKR boards with ATSAMD21 processor, some Teensy boards that also have many pins.
Please to not try to make a Joystick with the Mega board, you will get into a lot of trouble.

The link of my encoder is this: https://www.hohner.it/product-detail/serie-pr/
however in reality the pulsations are 1500 but with the code that I found the performance quadruples.
The LCD does not interest me because essentially I do not need it, it is present because the project (the code) is not mine but I found it somewhere else : https://easytromlabs.com/arduino/arduino-lab-09-leitura-de-um-encoder-industrial-heidenhain-com-o-arduino/

From this last link you can understand perhaps why I made those connections. Since I understand little of it, I ask you if in your opinion I can make the same connections with arduino leonardo

The English page for the encoder: https://www.encoder-hohner.com/product-detail/series-pr/.

It is just a normal rotary encoder, just like any other ordinary rotary encoder. That means the 'A' and 'B' signals are enough, you don't have to use the inverted signals.
I think all your need is the GND (1), 5V (2), A (3), B (4) and O (7)
Connect A and B to an interrupt pin, the Arduino Leonardo has 4 of them, and use the Encoder library.
I don't know the maximum rpm for that Encoder library.

Yes. The encoder-output is standard quadrature-output switching the signal LOW/HIGH and that's it. So almost any microcontroller can be used.

Well if you don't improve your knowledge about programming the future of your project looks like this:

every 5 to 20 minutes a new question arises why the modified code is not working as expected and how to do a modification to make it work.
Waiting minimum 10 minutes, mostly 60 minutes, sometimes 6 hours for an answer.

This forum supports helping to help yourself by

  • pointing to good tutorials
  • answering specific questions how to code something

as long as you show some own effort in learning programming.

If you don't show own effort:
over time more and more users will stay silent if you make a small modification posting the new compiler-error expecting to get full-service-support for correction.

So write about your learning style! What do you prefer:

  • videos that go quickly through the main things and offer written source-code
  • an online tutorial with pictures
  • a book

For sure there will questions arise and always if you have posted a project-specific question and you are waiting for an answer

I suggest to read at least two or three pages of an online-tutorial that serves learning programming.

For the learning-style reading / let run exercise-codes I recommend this tutorial:

Arduino Programming Course

It is easy to understand and has a good mixture between explaining important concepts and example-codes to get you going. So give it a try and report your opinion about this tutorial.

best regards Stefan

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