I've recently migrated from a Teensy 3.0 to a Teensy 3.1 board. I had written a sketch for the Teensy 3.0 board that obtains data from a Wii Nunchuk using I2C (communicating via pins 18 & 19, with pullup resistors to 3.3V). Below is the basic outline of my sketch:
Code:
#include <i2c_t3.h>
#define NUNCHUCK_ADDRESS 0x52
uint led_count;
void setup()
{
pinMode(13, OUTPUT);
pinMode(14, OUTPUT);
led_count = 0;
Joystick.useManualSend(true);
Wire.begin();
SendByte(0x55, 0xF0);
SendByte(0x00, 0xFB);
}
void loop()
{
int count = 0;
int values[6];
Wire.requestFrom(NUNCHUCK_ADDRESS, 6);
while(Wire.available())
{
values[count] = Wire.read();
count++;
}
... More Code here to process the data from the device ...
Joystick.sliderLeft(analogX+512);
Joystick.Zrotate(analogX+512);
Joystick.sliderRight(analogY+512);
Joystick.X(accelX);
Joystick.Y(accelY);
Joystick.Z(accelZ);
Joystick.button(1, zButton);
Joystick.button(2, cButton);
Joystick.hat(hatAngle);
Joystick.send_now();
SendByte(0x00, 0x00);
if (zButton > 0 || cButton > 0)
digitalWrite(14,HIGH);
else
digitalWrite(14,LOW);
if (led_count < 20)
digitalWrite(13,HIGH);
else
{
digitalWrite(13,LOW);
if (led_count > 30)
led_count = 0;
}
led_count++;
delay(10);
}
void SendByte(byte data, byte location)
{
Wire.beginTransmission(NUNCHUCK_ADDRESS);
Wire.write(location);
Wire.write(data);
if ( Wire.endTransmission() > 0)
{
//Do something
}
}
After resolving a compilation error that was occurring from the included i2c_t3 library (from help on this thread), I uploaded the sketch to my Teeny 3.1 (after choosing "Serial/Keyboard/Mouse/Joystick" in Tools>>USB Type in the Arduino environment). However, when I opened the Windows Game Controllers Control Panel (joy.cpl), the device was not showing up.
Unsure if there was a hardware or software problem, I connected the board in parallel with the Teensy 3.0 board (with the clock and data wires connected to both the Teensy 3.0 and 3.1 boards). I then uploaded the same sketch to each. The Teensy 3.0 board showed up in the Game Controllers Control Panel and was receiving/processing the data correctly, the Teensy 3.1 did not even show up.
I tried reinstalling the Arduino environment, as well as the Teensyduino uploader.
Any thoughts on what I'm doing wrong? Am I missing a driver of some kind for the Teensy 3.1?