[HN Gopher] Spinner-mouse: Arduino-based USB rotary controller f...
       ___________________________________________________________________
        
       Spinner-mouse: Arduino-based USB rotary controller for Arkanoid,
       Tempest, etc.
        
       Author : rcarmo
       Score  : 36 points
       Date   : 2024-03-26 09:28 UTC (13 hours ago)
        
 (HTM) web link (github.com)
 (TXT) w3m dump (github.com)
        
       | sleepybrett wrote:
       | friend of mine built this: https://www.instructables.com/HDDJ-
       | Turning-an-old-hard-disk-...
       | 
       | can't beat how smooth it is.
        
         | nativeit wrote:
         | This looks awesome. I'm going to try building one this evening.
         | It's interesting reading the comments from 14-15 years ago, the
         | capacity for hobbyists to do such things today is so much
         | greater, even just since 2010.
        
         | dylan604 wrote:
         | that's interesting. the switch from vinyl to any of the other
         | controllers was a very long time for me because I did not like
         | the feel of any of the control surfaces at the time. the
         | CDJ100s feel like fisher price toys which is probably what kept
         | the prices a fraction of the CDJ1000s which had a much more
         | acceptable feel. some of the digital only devices have gone
         | back to that cheap light plastic feel with just a horrible bit
         | of resistance.
         | 
         | i often wonder how people tolerate it, but then i realize most
         | people don't know what it was like playing vinyl and have
         | nothing to compare to.
        
       | tombert wrote:
       | I made something like this pretty recently, though it was with an
       | ESP32, and it was bluetooth, and I used a mouse driver. It was
       | cool, though I did kind of grow a hatred for the Arduino "poll
       | the pins in the loop" way of doing things. It would kind of work,
       | but the problem would be that if you spun the knob too quickly,
       | it would actually end up going backwards because you're
       | effectively spinning faster than it can sync.
       | 
       | I ended up having to learn how to use the FreeRTOS interrupts. It
       | was a bit harder but it was a much better play experience.
        
         | mikeInAlaska wrote:
         | What is causing the interrupts? Any change to encoder A or B?
        
           | tombert wrote:
           | You can set a gpio pin mode to PULLUP, and there's a function
           | built in to the freertos/arduino stuff for the ESP32 to
           | convert that gpio pin signal to an interrupt. From there you
           | can pass in a function pointer to run upon receiving the
           | interrupt.
           | 
           | The rotary encoder I bought simply applies pulses to one pin
           | when spinning clockwise, and another pin when spinning
           | counter clockwise, so I just attached the interrupts to two
           | separate gpio pins, and sent the updates to the mouse stuff
           | directly in the interrupt handler. I simply moved the mouse N
           | units to the right or left if going clockwise or
           | counterclockwise.
           | 
           | I'm sure it's not ideal but it worked to play breakout. I'm
           | still a little new to the world of microcontrollers so it's
           | possible that I did something dumb.
        
         | tomek_ycomb wrote:
         | It's a fun exercise in which I think you'll find polling to be
         | fine for many Arduino cases. Not as much for raspi and higher
         | level in my limited experience for various hardware reasons and
         | overhead. And quickly when you do other stuff, especially
         | blocking high level communication, polling does suffer. But
         | interrupts exist and are a reasonable level 2 for people to
         | learn.
         | 
         | https://www.mikrocontroller.net/articles/Drehgeber is an
         | excellent article (in German, Google translate is fine afaik.
         | Check the interrupt section
        
         | brokenmachine wrote:
         | >poll the pins in the loop
         | 
         | You should be using interrupts for encoders. The standard
         | Encoder library uses interrupts.
         | 
         | https://www.arduino.cc/reference/en/libraries/encoder/
         | 
         | In my experience on an ESP8266, it can do over 300kHz. Probably
         | faster on an ESP32. For ESP8266, just remember to set
         | ICACHE_RAM_ATTR for the ISR. Not sure if ESP32 is the same.
         | 
         | So you'd need to be turning those encoders pretty damn fast for
         | the interrupt speed to become a problem.
        
         | phkahler wrote:
         | >> if you spun the knob too quickly, it would actually end up
         | going backwards
         | 
         | The spinner on arcade Tempest can do the same. IIRC the
         | quadrature signals feed the clock and direction pins on a 4 bit
         | up-down counter on the board, and software probably polls the
         | counter. If you spin it fast enough (I used Teflon spray on
         | mine) you could wrap the counter around and get it to move
         | backwards. Something like that, it's been a few years...
        
       | robertclaus wrote:
       | It was refreshing to see an off-the-shelf project box on the
       | parts list rather than 3d printing it. I'm in the middle of a
       | multi-day printing spree for a project and am learning to
       | appreciate that not every generic box needs to be 3d printed.
        
       | joshmarinacci wrote:
       | I don't understand how it has a final resolution of 96 steps if
       | the hardware has 24 steps.
        
       ___________________________________________________________________
       (page generated 2024-03-26 23:00 UTC)