Jump to content
  • entries
    87
  • comments
    46
  • views
    71,251

Wii CLASSIC CONTROLLER + ARDUINO = ATARI JOYSTICK

k-Pack

1,917 views

Since I was successful getting the Wii Nunchuk hooked up to the Joystick port I thought I would try the Wii Classic Controller (WCC). The hardware was simple, unplug the nunchuk attached to the Arduino project from my last blog and plug in the WCC. It was my poor choice of internet search criterial that gave me the most trouble.

 

blogentry-37655-0-68639500-1418331209_thumb.jpg

 

I just needed to find the function library for the WCC. The first search pointed me to “playground.arduino.cc/Main/WiiClassicController”. This is a library created by Tim Hizel in May of 2008. The library and example program worked as stated but only reported the buttons once or twice and then reset, even if the button was still pressed.

 

I needed to be able to read the logic state while the button was pressed. Sooooo, it was back to the search engine. After a couple of days of half-hearted searching I decided that I would need to figure out why the button state reset and write my own library.

 

But that night there was a Christmas Miracle. I found myself wide awake at 4:00AM. Mostly due to the excitement from the anticipation of Santa’s arrival. After all, only 14 days till Christmas.

 

Anyway, I decided not to fight it and sat on the couch searching for the elusive library. I clicked on a search link and in a flash I was at “playground.arduino.cc/Main/WiiClassicController10” (see the difference?). This library is an exact replacement for Tim’s; written by Robbert Brandsman in 2012. It keeps the state of the buttons while they are pressed. Just what I needed.

 

Now load the following sketch. Change the #include to point to the WiiClassicController10 library you downloaded. Upload it to the Arduino and you are ready to play any game that requires the joystick.

 

The sketch uses the DPad for the direction control and the X or Y button for the trigger. I suppose if you got this far, you can modify the program to reflect your preferences.

 

Atari_Wii_Classic.ino

void setup(){  wiiClassy.begin();  wiiClassy.update();  pinMode(Up_Pin,OUTPUT);  pinMode(Down_Pin,OUTPUT);  pinMode(Left_Pin,OUTPUT);  pinMode(Right_Pin,OUTPUT);  pinMode(Trig_Pin,OUTPUT);}void loop() {  delay(10); // 1ms is enough to not overload the wii Classic, 100ms seems to ease the serial terminal a little  wiiClassy.update();    if (wiiClassy.upDPressed()) {digitalWrite(Up_Pin,HIGH);  }  else {digitalWrite(Up_Pin,LOW);}      if (wiiClassy.downDPressed()) {digitalWrite(Down_Pin,HIGH);  }  else {digitalWrite(Down_Pin,LOW);  }    if (wiiClassy.leftDPressed()) {digitalWrite(Left_Pin,HIGH);  }  else {digitalWrite(Left_Pin,LOW);  }    if (wiiClassy.rightDPressed()) {digitalWrite(Right_Pin,HIGH);  }  else {digitalWrite(Right_Pin,LOW);  }    if(wiiClassy.xPressed() || wiiClassy.yPressed()) {    digitalWrite(Trig_Pin,HIGH);  }  else {digitalWrite(Trig_Pin,LOW);  }  }

 

 

 

 

I’ve been using the Atari Joystick for so long that while playing Missile Command with the WCC I noticed my left thumb was taping the DPad, as if it was a big red button. A reboot ain’t guna correct that problem.

 

  • Like 1


0 Comments


Recommended Comments

There are no comments to display.

Guest
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.

Loading...
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...