Digistump News  RSS Feed
Posted on 05/22/2013 | share
We pleased to announce our two newest products!

The Nunchuck Shield for the Digispark - which allows you to attach a Nintendo Wii Nunchuck to your Digispark and use the accelerometer, analog stick, and buttons for your project (robot control!) or send the data to the computer over USB. With the included example you can even use it as a USB joystick!




We've produced these in pretty limited quantities so get them while they last - and we'll make a bunch more if they are popular!

Due to the limited quantity we don't have the raw PCB available separately right now, but will as soon as we get more boards in stock.



Project of the Day!



The project of the day (a shameless plug perhaps, but we think it is pretty cool!) is using your Nunchuck as a joystick. The newest software release has all the required libraries and includes this code example:

Full code after the break                                                            

//DigiJoystick Nunchuck Demo

#include 
#include 
#include 

ArduinoNunchuk nunchuk = ArduinoNunchuk();

void setup() {
  nunchuk.init();
}


void loop() {
  nunchuk.update();
  DigiJoystick.setX((byte) nunchuk.analogX); // scroll X left to right repeatedly
  DigiJoystick.setY((byte) nunchuk.analogY);
  DigiJoystick.setXROT((byte) map(nunchuk.accelX,255,700,0,255));
  DigiJoystick.setYROT((byte) map(nunchuk.accelY,255,850,0,255));
  DigiJoystick.setZROT((byte) map(nunchuk.accelZ,255,750,0,255));
  int buttonByte = 0;
  bitWrite(buttonByte, 0, nunchuk.zButton);
  bitWrite(buttonByte, 1, nunchuk.cButton);
  DigiJoystick.setButtons((byte) buttonByte, (byte) 0);
  DigiJoystick.delay(10); 
  
  
}

That's all it takes! Attach the Nunchuck to the I2C lines of the Digispark (with pullups - or use the Nunchuck Shield ), plug the Digispark into the computer and it shows up as a USB joystick - buttons one and two are the buttons, each rotation axis is mapped to the rotation of the Nunchuck, and the analog stick is the actual joystick control. We think this makes the Digispark one of the cheapest, fastest, easiest ways to connect a Nunchuck to a computer.

You could even use it as a mouse by using the DigisparkMouse example and changing it to use the Nunchuck data for mouse movement.




More Posts