adruino rf module xbox

6
[DIL ISI LIB] DIL'S SOMEWHAT POINTLESS BLOG Subscribe via RSS Sub HOME Page 1 of 6 Xbox 360 RF module + Arduino « [dil isi lib] 2/6/2012 http://diru.org/wordpress/hacking/xbox-360-rf-module-arduino/

Upload: spdlcr5

Post on 13-Apr-2015

173 views

Category:

Documents


3 download

DESCRIPTION

adruino hookup to xbox 360 wireless adapter

TRANSCRIPT

Page 1: Adruino Rf Module Xbox

[DIL ISI LIB] DIL'S SOMEWHAT POINTLESS BLOG Subscribe via RSS

SubHOME

Page 1 of 6Xbox 360 RF module + Arduino « [dil isi lib]

2/6/2012http://diru.org/wordpress/hacking/xbox-360-rf-module-arduino/

Page 2: Adruino Rf Module Xbox

Xbox 360 RF module + ArduinoI was going to make a huge write-up on this, but I can't be bothered right now. I'll probably do something about it later. Until then, have an Arduino sketch. If you don't know what you're doing with it then chances are you don't have an Arduino, in which case the file is useless to you.

The sketch:

/* Arduino code to communicate with xbox 360 RF module.

Original work by (yaywoop) / additional ideas from Alexander Martinez -

modified by dilandou (www.dilandou.com, www.diru.org/wordpress)

First sends LED initialisation code followed by LED startup animation code, then sleeps u

RF module must be powered with 3.3V, two diodes in series with USB 5v will do. Connect th

of course, make sure to have a common ground */

#include <avr/sleep.h>

#define sync_pin 2 //power button repurposed for sync button (pin 5 on the module)

#define data_pin 3 //data line (pin 6 on the module)

#define clock_pin 4 //clock line (pin 7 on module)

int led_cmd[10] = {0,0,1,0,0,0,0,1,0,0}; //Activates/initialises the LEDs, leaving

the center LED lit.

int anim_cmd[10] = {0,0,1,0,0,0,0,1,0,1}; //Makes the startup animation on the ring

of light.

int sync_cmd[10] = {0,0,0,0,0,0,0,1,0,0}; //Initiates the sync process.

volatile boolean sync_enable = 0;

void sendData(int cmd_do[]) {

pinMode(data_pin, OUTPUT);

digitalWrite(data_pin, LOW); //start sending data.

int prev = 1;

for(int i = 0; i < 10; i++){

while (prev == digitalRead(clock_pin)){} //detects change in clock

prev = digitalRead(clock_pin);

// should be after downward edge of clock, so send bit of data now

digitalWrite(data_pin, cmd_do[i]);

while (prev == digitalRead(clock_pin)){} //detects upward edge of clock

prev = digitalRead(clock_pin);

}

digitalWrite(data_pin, HIGH);

pinMode(data_pin, INPUT);

}

void initLEDs(){

sendData(led_cmd);

delay(50);

sendData(anim_cmd);

delay(50);

}

void wakeUp(){

sync_enable = 1;

}

void sleepNow() {

set_sleep_mode(SLEEP_MODE_PWR_DOWN); // set sleep mode

sleep_enable(); //enable sleep bit

attachInterrupt(0, wakeUp, LOW);

sleep_mode();

sleep_disable(); //disable sleep bit

detachInterrupt(0); // disables interrupt 0 on pin 2

}

void setup() {

Serial.begin(9600);

pinMode(sync_pin, INPUT);

digitalWrite(sync_pin,HIGH);

pinMode(data_pin, INPUT);

pinMode(clock_pin, INPUT);

delay(2000);

initLEDs();

// sendData(sync_cmd);

}

void loop(){

Serial.println("Sleeping.");

sleepNow();

delay(200);

if(sync_enable==1) {

Site

About dil

Charity

Hacking

Xbox 360 RF module +

Arduino

Parody

A collection of unused

nooses!

Look! A big fat fairy!

Magic profile views tracker

chest!!

Play Pissass-Annoying-

Farmvizombimafipirate

wars!

Vegetable patch needs

watering!

Archives

December 2011

May 2011

April 2011

March 2011

February 2011

January 2011

December 2010

November 2010

October 2010

September 2010

December 2009

Categories

3d

Charity

Electronics

Learning

Life

Productivity

Rants

Social

Travel

Meta

Log in

Entries RSS

Comments RSS

WordPress.org

Page 2 of 6Xbox 360 RF module + Arduino « [dil isi lib]

2/6/2012http://diru.org/wordpress/hacking/xbox-360-rf-module-arduino/

Page 3: Adruino Rf Module Xbox

iScypek

August 3rd, 2011 - 14:07

I have ATMEGA8 uC, could you send me hex file for arduino with this uC? I triet to compile it on arduino, but i have only project file and i dont know the path of hex files.

( REPLY )

dilandou

August 3rd, 2011 - 19:47

In the Arduino IDE, hold Shift while clicking the Upload button. This triggers verbose mode, and will show where the hex file is temporarily held. The hex files are deleted as soon as you close the IDE.

( REPLY )

Goddard

August 5th, 2011 - 09:47

cool.. appreciate the work you have put in.

( REPLY )

Adil October 30th, 2011 - 18:02

wer do we type these??????

( REPLY )

Serial.println("Syncing.");

sendData(sync_cmd);

sync_enable = 0;

}

}

Comments (16) Trackbacks (0) ( subscribe to comments on this post )

Page 3 of 6Xbox 360 RF module + Arduino « [dil isi lib]

2/6/2012http://diru.org/wordpress/hacking/xbox-360-rf-module-arduino/

Page 4: Adruino Rf Module Xbox

dilandou

October 30th, 2011 - 18:25

This is code for the Arduino. It’s pasted into the Arduino IDE.

( REPLY )

Michael Rogers December 29th, 2011 - 14:26

This controls the sync process and state of the leds. Am I correct in assuming that the state of the controller buttons are not accessible to the arduino, but over usb only?

( REPLY )

dilandou

December 29th, 2011 - 17:09

To be honest, I haven’t dug that far into it. I was planning on a little experimentation, but never got around to it. What I do know is that when you send certain commands to the RF unit, it will send data back over the same line. I think, however, it’s mostly things like “I have X controllers connected” or “This controller is controller X” etc. Useful for fine tuning the lights, if you wanted to be more fancy, but not much else.

( REPLY )

Timinator01

January 16th, 2012 - 21:01

my controller wont sync … the module does the sync light animation and so does the controller but they wont do it at the same time. when both are syncing it automatically starts all leds flashing and then the module stops and the controller just keeps flashing instead of a player # light turning on like with a real xbox. any ideas on how to fix this? the xbox rf module is x802779-010 rev:A-1-1 and the controllers are x809478-001 and x817145-006 (i think these are the model numbers)

( REPLY )

dilandou

January 16th, 2012 - 21:32

Sounds like a bit of a dumb question, and I apologise for asking it, but when you say the sync animation, you mean after you’ve pressed the center button and not the animation when it’s first powered on, correct?

Also, the module itself won’t have an LED lit to show it has a controller connected. Unfortunately it would require figuring out the data sequence it replies with to say what number controller is connected, then telling it to light whichever LED. Extra effort for an entirely cosmetic feature. :P

It would seem that there’s a rev B hardware now with different pinouts. It’s easily identified with the RF02 moniker. The main differences seem to be DATA on pin 7, and CLK on pin 9 (at 130hz).

( REPLY )

Page 4 of 6Xbox 360 RF module + Arduino « [dil isi lib]

2/6/2012http://diru.org/wordpress/hacking/xbox-360-rf-module-arduino/

Page 5: Adruino Rf Module Xbox

phrost January 20th, 2012 - 16:07

Is it possible to use this to control servos without needing a pc to send the data over serial?

( REPLY )

dilandou

January 20th, 2012 - 16:41

There are people asking a similar thing here: http://forums.xbox-experts.com/viewtopic.php?t=4029&p=26982

Personally I’ve not gone that deep into it as I’m not confident enough to start reverse engineering protocols. From the seems of it, though, the general idea is that you could either set a uC up as a USB host and decode whatever data is sent over USB, or directly hook into the logic going between the RF chip and the USB chip and use the raw data from there. If you have a logic analyser or oscilloscope give it a try. I’d be curious to know the results myself.

( REPLY )

Chris January 27th, 2012 - 18:56

Hi there, I was wondering if I could get a quick schematic that corresponds with the code posted here. I have only worked with Motorola chips and assembly in the past and don’t have much experience with the arduino, it’s libraries, and much c.

I’ve gone ahead and made sense of the code (save a few lines) and I would like to confirm a few speculations based on the arduino’s pinout and a schematic.

Sorry for the trouble.

( REPLY )

dilandou

January 27th, 2012 - 22:49

I’ve added a schematic to the bottom of the post. It’s pretty simple so far as things go. If you’re paranoid about the logic being above the 3.3V supply for the board, you can either ignore it, or stick some voltage dividers in there, but considering the logic only happens for -very- short times, it’s mostly unnecessary.

If you wanted a more permanent and less wire hogging solution, you could always power the Arduino from the usb supply powering the RF module. Essentially the only need for the Arduino to have a USB connection is for the serial debugging (which you can safely remove from the code).

Personally I’ve moved the whole thing over to an ATTINY45 soldered directly onto the board. Using an Arduino permanently is a wee bit overkill, afterall.

( REPLY )

Brawrf February 3rd, 2012 - 17:35

I miss data on how the Arduino is powered here. I’d also like to know the current draw of the module, because it might be possible to pair everything up in a nice looking setup.

( REPLY )

Page 5 of 6Xbox 360 RF module + Arduino « [dil isi lib]

2/6/2012http://diru.org/wordpress/hacking/xbox-360-rf-module-arduino/

Page 6: Adruino Rf Module Xbox

Copyright © 2012 [dil isi lib] · Powered by WordPress

Lightword Theme by Andrei Luca Go to top ↑

dilandou

February 3rd, 2012 - 17:39

Two choices for power, really. Either plug the arduino in separately when it’s needed for syncing, or tie it in to the USB cable before the diodes. As for current draw, device manager is reporting 260mA. I’m not going to argue with it.

( REPLY )

Robin Chan

February 4th, 2012 - 19:49

personally i dont think your going to be able to use it to be able to sniff buttons using only commands.

I think its a pretty simple USB HID interface? Arduinos can host these. I’m sure I’ve even heard of some people bit banging HID hosts.

…try setting an arduino up in HID host mode and implementing a simple joypad sketch.

( REPLY )

Leave a comment

Name (required)

Email (required)

Website

55

66

Submit

Type the two words:

Page 6 of 6Xbox 360 RF module + Arduino « [dil isi lib]

2/6/2012http://diru.org/wordpress/hacking/xbox-360-rf-module-arduino/