I'm attempting to use a SparkFun bidirectional level shifter (Link here) to connect up a 3.3v wii nunchuk to a 5v Arduino Uno circuit. For now all I'm trying to do is write the position of the joystick and buttons into the monitor. When I include the shifter in the circuit, the code returns values that are way off what they should be, into the thousands or sometimes minuses. However, when I connect the controller without the shifter (at risk of burning out my controller), the code runs as normal, returning back the x and y axis of the joystick at around 130. Both push buttons have a similar issue, where they read as pressed at random intervals when not even touched. What could be causing the data to be off? I've tried rewiring several times, and am following the SparkFun general use page as a guide, and so hopefully miswiring shouldn't be the issue.
Here is the code:
#include <Wire.h>
#include <ArduinoNunchuk.h>
#define BAUDRATE 19200
ArduinoNunchuk nunchuk = ArduinoNunchuk();
void setup()
{
Serial.begin(BAUDRATE);
nunchuk.init();
}
void loop()
{
nunchuk.update();
Serial.print(nunchuk.analogX, DEC);
Serial.print(' ');
Serial.print(nunchuk.analogY, DEC);
Serial.print(' ');
Serial.print(nunchuk.zButton, DEC);
Serial.print(' ');
Serial.println(nunchuk.cButton, DEC);
Serial.print(' ');
delay(250);
}
Library source :http://www.gabrielbianconi.com/projects/arduinonunchuk/