zhanggang1971 发表于 2011-12-19 21:24:48

关于WII的鸡腿控接口

在视频网站上看到有人用WII的鸡腿控来控制小车或者舵机,感觉很酷,不知坛子里的那位大侠知道如何从鸡腿控里读取摇杆,按钮以及里面加速度计的接口,有没有库文件?{:soso_e100:}

风的孩子 发表于 2011-12-20 13:07:19

这个东西你可以在谷歌里面搜索。

关键是要找出它每个发出的信号所代表的意思。

现成的库文件貌似还没有,要不,你折腾一下,然后开源出来?

zhanggang1971 发表于 2011-12-20 13:12:53

风的孩子 发表于 2011-12-20 13:07 static/image/common/back.gif
这个东西你可以在谷歌里面搜索。

关键是要找出它每个发出的信号所代表的意思。


唉,我要是有这个本事就不是小白啦。昨天刚刚拆了一个鸡腿控,上面的引线上有标识,先送信号试试看吧

风的孩子 发表于 2011-12-20 13:25:01

介个。。。你不需要拆呀。。。
你可以插上位机上面,然后直接读取它的信号呀。
我以前乱翻资料的时候记得,它的接口是IIC总线的接口。
但是电压是多少忘记了。
arduino 硬件直接支持iic。

zhanggang1971 发表于 2011-12-20 16:20:55

风的孩子 发表于 2011-12-20 13:25 static/image/common/back.gif
介个。。。你不需要拆呀。。。
你可以插上位机上面,然后直接读取它的信号呀。
我以前乱翻资料的时候记得 ...

是的,鸡腿控支持IIC的,俺不会上位机,直接拆了,晚上接出引脚,插面包板,看看会不会烧糊,等我消息呵呵。

弘毅 发表于 2011-12-20 17:28:49

电源不要接反就没事。。。。鸡腿很便宜,貌似国产的不到20

三水 发表于 2011-12-20 20:13:32

本帖最后由 三水 于 2012-2-28 14:00 编辑

http://todbot.com/blog/2008/02/18/wiichuck-wii-nunchuck-adapter-available/
http://letsmakerobots.com/node/5684这个东西是楼主要吗的?

zhanggang1971 发表于 2011-12-20 22:14:39

三水 发表于 2011-12-20 20:13 static/image/common/back.gif
http://todbot.com/blog/2008/02/18/wiichuck-wii-nunchuck-adapter-available/
http://letsmakerobots.co ...

:'( 我泪牛满面,就是要找这个啊,确实不用拆啊,我不仅拆了,还把摇柄的电位器给焊下来了,而且焊不回去了。买的国产鸡腿,19块一个,这是最便宜的买三轴加速度计的方式了,可是运费要十块!

感谢三水版主 :victory:

三水 发表于 2011-12-20 22:36:31

http://www.ourdev.cn/bbs/bbs_content.jsp?bbs_sn=5174251&bbs_page_no=1&bbs_id=1025如果拆了可以参考下这个

Micky 发表于 2011-12-21 03:12:02

这个我有,留个爪,明晚发

Micky 发表于 2011-12-21 17:15:17

/*
* NunchuckPrint
*
* 2007 Tod E. Kurt, http://todbot.com/blog/
*
* The Wii Nunchuck reading code is taken from Windmeadow Labs
*   http://www.windmeadow.com/node/42
*/

#include <Wire.h>

void setup()
{
Serial.begin(19200);
nunchuck_setpowerpins(); // use analog pins 2&3 as fake gnd & pwr
nunchuck_init(); // send the initilization handshake
Serial.print ("Finished setup\n");
}

void loop()
{
nunchuck_get_data();
nunchuck_print_data();
delay(100);
}


//
// Nunchuck functions
//

static uint8_t nunchuck_buf;   // array to store nunchuck data,

// Uses port C (analog in) pins as power & ground for Nunchuck
static void nunchuck_setpowerpins()
{
#define pwrpin PORTC3
#define gndpin PORTC2
DDRC |= _BV(pwrpin) | _BV(gndpin);
PORTC &=~ _BV(gndpin);
PORTC |=_BV(pwrpin);
delay(100);// wait for things to stabilize      
}

// initialize the I2C system, join the I2C bus,
// and tell the nunchuck we're talking to it
void nunchuck_init()
{
Wire.begin();                      // join i2c bus as master
Wire.beginTransmission(0x52);        // transmit to device 0x52
Wire.send(0x40);                // sends memory address
Wire.send(0x00);                // sends sent a zero.
Wire.endTransmission();        // stop transmitting
}

// Send a request for data to the nunchuck
// was "send_zero()"
void nunchuck_send_request()
{
Wire.beginTransmission(0x52);        // transmit to device 0x52
Wire.send(0x00);                // sends one byte
Wire.endTransmission();        // stop transmitting
}

// Receive data back from the nunchuck,
int nunchuck_get_data()
{
int cnt=0;
Wire.requestFrom (0x52, 6);        // request data from nunchuck
while (Wire.available ()) {
    // receive byte as an integer
    nunchuck_buf = nunchuk_decode_byte(Wire.receive());
    cnt++;
}
nunchuck_send_request();// send request for next data payload
// If we recieved the 6 bytes, then go print them
if (cnt >= 5) {
    return 1;   // success
}
return 0; //failure
}

// Print the input data we have recieved
// accel data is 10 bits long
// so we read 8 bits, then we have to add
// on the last 2 bits.That is why I
// multiply them by 2 * 2
void nunchuck_print_data()
{
static int i=0;
int joy_x_axis = nunchuck_buf;
int joy_y_axis = nunchuck_buf;
int accel_x_axis = nunchuck_buf; // * 2 * 2;
int accel_y_axis = nunchuck_buf; // * 2 * 2;
int accel_z_axis = nunchuck_buf; // * 2 * 2;

int z_button = 0;
int c_button = 0;

// byte nunchuck_buf contains bits for z and c buttons
// it also contains the least significant bits for the accelerometer data
// so we have to check each bit of byte outbuf
if ((nunchuck_buf >> 0) & 1)
    z_button = 1;
if ((nunchuck_buf >> 1) & 1)
    c_button = 1;

if ((nunchuck_buf >> 2) & 1)
    accel_x_axis += 2;
if ((nunchuck_buf >> 3) & 1)
    accel_x_axis += 1;

if ((nunchuck_buf >> 4) & 1)
    accel_y_axis += 2;
if ((nunchuck_buf >> 5) & 1)
    accel_y_axis += 1;

if ((nunchuck_buf >> 6) & 1)
    accel_z_axis += 2;
if ((nunchuck_buf >> 7) & 1)
    accel_z_axis += 1;

Serial.print(i,DEC);
Serial.print("\t");

Serial.print("joy:");
Serial.print(joy_x_axis,DEC);
Serial.print(",");
Serial.print(joy_y_axis, DEC);
Serial.print("\t");

Serial.print("acc:");
Serial.print(accel_x_axis, DEC);
Serial.print(",");
Serial.print(accel_y_axis, DEC);
Serial.print(",");
Serial.print(accel_z_axis, DEC);
Serial.print("\t");

Serial.print("but:");
Serial.print(z_button, DEC);
Serial.print(",");
Serial.print(c_button, DEC);

Serial.print("\r\n");// newline
i++;
}

// Encode data to format that most wiimote drivers except
// only needed if you use one of the regular wiimote drivers
char nunchuk_decode_byte (char x)
{
x = (x ^ 0x17) + 0x17;
return x;
}

zhanggang1971 发表于 2011-12-21 18:07:08

Micky 发表于 2011-12-21 17:15 static/image/common/back.gif


万分感谢,我回去试一试. :handshake

风的孩子 发表于 2011-12-22 18:58:58

呵呵。期待你把wii的控制信号给倒腾出来。
页: [1]
查看完整版本: 关于WII的鸡腿控接口