Jump to content
  • entries
  • comments
  • views

Nunchuk Your Way To a Better Pac-man Score




While playing Pac-man with a standard Atari Joystick, how often have you missed a turn? I may have a solution, if its due to pushing the joystick to far off the four directional axis. If its due to a slow reaction time then you're still on your own.


I noted while playing Pac-man that my granddaughter would rotate the joystick base and start pushing the joystick into the diagonal directions(and so was I to a lesser extent). When 2 directional buttons on the joystick are pressed Pac-man determines that you are not sure which way you want him to go and continues to the end the lane.


An Arduino can be used to read a Wii nunchuk analog joystick and determine which of the 4 directions it is closest to and then set the joystick pins. This would double the acceptable error from true UP, DOWN, LEFT and RIGHT.



I believe it has improved my Pac-man scores. The first time I used the setup I was able to advance to level 2. The second try got me to level 3. The third game got me to level three with a personal high score of 12,200 points. I'm getting the feeling that I'm RTC (Reaction Time Challenged)?


What to do?


My first Out of the Pack blog project was using the nunchuk as an Atari Joystick. The circuit hasn't changed much and is still using the same Arduino library from a slightly modified program from "Arduino: A Quick-Start Guide" by Maik Schmidt. You'll need some of this information.




The prototype shield built for the Synthdrum project was reused. This shield has been getting a lot of use . A reset button has been added since the last time it was photographed. You can even leave the MIDI shield plugged on the stack but be sure to turn it off.



The Arduino program is simple enough. Of course, I could have saved myself a couple of days of frustration if I had paid closer attention in trigonometry class. I can still remember 45 years ago saying to myself, "When am I ever going to use this crap."


I suppose that it would have been easier to download the MATH library with the required functions to calculate angles but I found a way…….




1. Read the nunchuk x,y

2. Adjust x,y to 0,0 point of origin.

3. Calculate the Radius of a circle through adjusted x,y (a^2=b^2+c^2)

4. Use SIN,COS table to calculate XY limit points at the 45deg limits

5. Determine which limit points the XY is between.

6. Set the joystick port

7. Check the button status

8. Start over.


Most of the testing was done with the unit plugged into the ATARI8 and using the following program.


10 X=STRIG(0):Y=15-STICK(0)



40 GOTO 10


Then I remembered that I had made the Joystick Tester for just this situation and that worked too.



  • Like 1


Recommended Comments

There are no comments to display.

Add a comment...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...