极客工坊

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 22061|回复: 12

关于WII的鸡腿控接口

[复制链接]
发表于 2011-12-19 21:24:48 | 显示全部楼层 |阅读模式
在视频网站上看到有人用WII的鸡腿控来控制小车或者舵机,感觉很酷,不知坛子里的那位大侠知道如何从鸡腿控里读取摇杆,按钮以及里面加速度计的接口,有没有库文件?{:soso_e100:}
回复

使用道具 举报

发表于 2011-12-20 13:07:19 | 显示全部楼层
这个东西你可以在谷歌里面搜索。

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

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

回复 支持 反对

使用道具 举报

 楼主| 发表于 2011-12-20 13:12:53 | 显示全部楼层
风的孩子 发表于 2011-12-20 13:07
这个东西你可以在谷歌里面搜索。

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

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

使用道具 举报

发表于 2011-12-20 13:25:01 | 显示全部楼层
介个。。。你不需要拆呀。。。
你可以插上位机上面,然后直接读取它的信号呀。
我以前乱翻资料的时候记得,它的接口是IIC总线的接口。
但是电压是多少忘记了。
arduino 硬件直接支持iic。
回复 支持 反对

使用道具 举报

 楼主| 发表于 2011-12-20 16:20:55 | 显示全部楼层
风的孩子 发表于 2011-12-20 13:25
介个。。。你不需要拆呀。。。
你可以插上位机上面,然后直接读取它的信号呀。
我以前乱翻资料的时候记得 ...

是的,鸡腿控支持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/1 ... -adapter-available/
http://letsmakerobots.com/node/5684这个东西是楼主要吗的?
回复 支持 反对

使用道具 举报

 楼主| 发表于 2011-12-20 22:14:39 | 显示全部楼层
三水 发表于 2011-12-20 20:13
http://todbot.com/blog/2008/02/18/wiichuck-wii-nunchuck-adapter-available/
http://letsmakerobots.co ...

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

感谢三水版主
回复 支持 反对

使用道具 举报

发表于 2011-12-20 22:36:31 | 显示全部楼层
http://www.ourdev.cn/bbs/bbs_con ... o=1&bbs_id=1025如果拆了可以参考下这个
回复 支持 反对

使用道具 举报

发表于 2011-12-21 03:12:02 | 显示全部楼层
这个我有,留个爪,明晚发
回复 支持 反对

使用道具 举报

发表于 2011-12-21 17:15:17 | 显示全部楼层
  1. /*
  2. * NunchuckPrint
  3. *
  4. * 2007 Tod E. Kurt, http://todbot.com/blog/
  5. *
  6. * The Wii Nunchuck reading code is taken from Windmeadow Labs
  7. *   http://www.windmeadow.com/node/42
  8. */

  9. #include <Wire.h>

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

  17. void loop()
  18. {
  19.   nunchuck_get_data();
  20.   nunchuck_print_data();
  21.   delay(100);
  22. }


  23. //
  24. // Nunchuck functions
  25. //

  26. static uint8_t nunchuck_buf[6];   // array to store nunchuck data,

  27. // Uses port C (analog in) pins as power & ground for Nunchuck
  28. static void nunchuck_setpowerpins()
  29. {
  30. #define pwrpin PORTC3
  31. #define gndpin PORTC2
  32.   DDRC |= _BV(pwrpin) | _BV(gndpin);
  33.   PORTC &=~ _BV(gndpin);
  34.   PORTC |=  _BV(pwrpin);
  35.   delay(100);  // wait for things to stabilize        
  36. }

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

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

  55. // Receive data back from the nunchuck,
  56. int nunchuck_get_data()
  57. {
  58.   int cnt=0;
  59.   Wire.requestFrom (0x52, 6);        // request data from nunchuck
  60.   while (Wire.available ()) {
  61.     // receive byte as an integer
  62.     nunchuck_buf[cnt] = nunchuk_decode_byte(Wire.receive());
  63.     cnt++;
  64.   }
  65.   nunchuck_send_request();  // send request for next data payload
  66.   // If we recieved the 6 bytes, then go print them
  67.   if (cnt >= 5) {
  68.     return 1;   // success
  69.   }
  70.   return 0; //failure
  71. }

  72. // Print the input data we have recieved
  73. // accel data is 10 bits long
  74. // so we read 8 bits, then we have to add
  75. // on the last 2 bits.  That is why I
  76. // multiply them by 2 * 2
  77. void nunchuck_print_data()
  78. {
  79.   static int i=0;
  80.   int joy_x_axis = nunchuck_buf[0];
  81.   int joy_y_axis = nunchuck_buf[1];
  82.   int accel_x_axis = nunchuck_buf[2]; // * 2 * 2;
  83.   int accel_y_axis = nunchuck_buf[3]; // * 2 * 2;
  84.   int accel_z_axis = nunchuck_buf[4]; // * 2 * 2;

  85.   int z_button = 0;
  86.   int c_button = 0;

  87.   // byte nunchuck_buf[5] contains bits for z and c buttons
  88.   // it also contains the least significant bits for the accelerometer data
  89.   // so we have to check each bit of byte outbuf[5]
  90.   if ((nunchuck_buf[5] >> 0) & 1)
  91.     z_button = 1;
  92.   if ((nunchuck_buf[5] >> 1) & 1)
  93.     c_button = 1;

  94.   if ((nunchuck_buf[5] >> 2) & 1)
  95.     accel_x_axis += 2;
  96.   if ((nunchuck_buf[5] >> 3) & 1)
  97.     accel_x_axis += 1;

  98.   if ((nunchuck_buf[5] >> 4) & 1)
  99.     accel_y_axis += 2;
  100.   if ((nunchuck_buf[5] >> 5) & 1)
  101.     accel_y_axis += 1;

  102.   if ((nunchuck_buf[5] >> 6) & 1)
  103.     accel_z_axis += 2;
  104.   if ((nunchuck_buf[5] >> 7) & 1)
  105.     accel_z_axis += 1;

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

  108.   Serial.print("joy:");
  109.   Serial.print(joy_x_axis,DEC);
  110.   Serial.print(",");
  111.   Serial.print(joy_y_axis, DEC);
  112.   Serial.print("  \t");

  113.   Serial.print("acc:");
  114.   Serial.print(accel_x_axis, DEC);
  115.   Serial.print(",");
  116.   Serial.print(accel_y_axis, DEC);
  117.   Serial.print(",");
  118.   Serial.print(accel_z_axis, DEC);
  119.   Serial.print("\t");

  120.   Serial.print("but:");
  121.   Serial.print(z_button, DEC);
  122.   Serial.print(",");
  123.   Serial.print(c_button, DEC);

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

  127. // Encode data to format that most wiimote drivers except
  128. // only needed if you use one of the regular wiimote drivers
  129. char nunchuk_decode_byte (char x)
  130. {
  131.   x = (x ^ 0x17) + 0x17;
  132.   return x;
  133. }
复制代码
回复 支持 反对

使用道具 举报

 楼主| 发表于 2011-12-21 18:07:08 | 显示全部楼层
Micky 发表于 2011-12-21 17:15

万分感谢,我回去试一试.
回复 支持 反对

使用道具 举报

发表于 2011-12-22 18:58:58 | 显示全部楼层
呵呵。期待你把wii的控制信号给倒腾出来。
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则 需要先绑定手机号

Archiver|联系我们|极客工坊

GMT+8, 2024-4-19 12:48 , Processed in 0.042965 second(s), 21 queries .

Powered by Discuz! X3.4 Licensed

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表