Making a rotary sensor an input device to computer

Hello, this is my first project.
I have little to no experience in coding so I decided to ask for help here.

So I’ve set up my breadboard with a Nucleo F303K8 and a rotary sensor. My idea was to make the rotary sensor into a game controller. For that I need to make this sensor output a key, for example W, for every click/turn (?) it makes.

I used D10 for Switch, D9 for Clock, and D8 for Data, if that helps.

No idea how to make it work, any help would be appreciated.

Hello,

Are you sure, this is the best way? Maybe a video of C++ basics and Arduino could be much better, for a starting point. I also started here as a newbe few years ago, but I had some experiences from VBA an VB (.Net).
Also usually is good to do an effort by yourself and when you will stuck, then you can ask.

What do you want to connect the controller to and how?
For example PC. PC controllers are usually connected to PC as USB HID device. But your board does not have USB interface (It has nothing to do with the onboard USB connector). So without an additional hardware (that also add additional complications) you are not able to connect it to PC.

Please be so kind and share some information about your sensor, product name for example.

BR, Jan

Thanks for the reply! I really appreciate it.

That actually answered a lot of questions. I didn’t know whether it was possible or not, just had some things laying around my house and finally decided to put some use to them, as well try out some coding where I totally over expected the difficulty level.

For the sensor, I made a mistake. It’s actually an encoder not sensor, that’s if there’s any difference. I don’t remember the exact name though, I’ve had it for a long time. I know that it’s one without a breakout.

So then, if i wanted to make this idea into a real thing, I should get a board with a HID. Would there be any boards with HID that you would recommend for me as a beginner? I’ve wanted to get the Arduino UNO for a while, would that work in my need?

Probably achivable it is with a cheap bluephil board, it can be very usefull for this simple task (read an input and send to an output, in this case rotary encoder to USB). Probably not ideal for start, because USBDEVICE is not supported in Mbed (not sure about actual situation) but it seems to be achivable cuz an old external library exist. Maybe @hudakz can bring some light.

Good choice could be mbed LPC1768 | Mbed, very popular and very funkcional. Then take a look to USBKeyboard - API references and tutorials | Mbed OS 6 Documentation

I had not so much personal experiences with Arduino, but we can say, Arduino UNO could be good for your start. And it is easy to find something for it. Just type to google what do you want and add Arduino word - Arduino UNO HID controller.

BR, Jan

Hello Daniel,

As Jan said the BLUEPILL used to be a very good deal. But because of the pandemic the prices changed a lot. I think the best deal (features/price) seems to be now the BLACKPILL board for about €3 (512kB flash, 96kB SRAM, 84MHz Core Clock) or €6 (512kB flash, 128KB, 100MHz Core Clock). At about the same price the BLACKPILL has additional advantages compared to the BLUEPILL:

              | BLUEPILL | BLACKPILL |
Flash size    |    128kB |     512kB |
SRAM          |     20kB |  96/128kB |
Core Clock    |    75MHz | 84/100MHz |
Cortex        |       M3 |        M4 |
USB on Mbed 6 |       no |       yes | 
Price/piece   |    €2.50 |     €3/€6 |

Please notice that the official mbed-enabled boards are equipped with an on-board programmer/debugger (probe). However, for the custom boards (like for example the BLUEPILL or BLACKPILL) you will need an external programmer (probe), for example as this one . Nevertheless, you can program the ARM Cortex M chips also using a built-in bootloader and a USB to UART TTL converter.

1 Like