after reading and reading a lot about encoders and scroll wheels used for controlling motors and other stuff,
i finally am totally out of clue how to finally program a scroll wheel encoder to act as a scroll wheel for the PC like the regular scroll wheel on a simple mouse does.
I want to use a scroll wheel encoder in my arduino joystick mouse to act as a scroll wheel.
I got everything working with the joystick and the buttons and just want to add the encoder to it.
Now my problem is:
How would i include this encoder in the sketch using the Mouse.h library with Mouse.move and the wheel command or
do i have to use the Encoder.h library additionaly to finally solve my problem and how to include this ?
i am stuck and hope anybody can help me getting this done,
You need to read the encoder somehow. The easiest way to do that is with the Encoder library. If you don't like doing things the easy way, you can write your own code to read the encoder. It's not too difficult for the low RPM of this application.
My advice is to start by writing a program that reads the encoder and prints the value to the Serial Monitor. Don't mess with the Mouse library at all at this point as it just adds in unnecessary complexity. If you're using an encoder library, chances are it comes with an example sketch that does this. So you won't even need to write the code. Once you've verified that you can read good data from the encoder, you can then incorporate that into your mouse code.
i found a sketch that i changed a bit to my desire and in the serial printer it is working and even the scrollbar scrolls.
Actually it is not very precise and bouncy and in the sketch after i delete the serial print it doesnt work at all anymore.
Where do i do something wrong and what do i miss?