Arc Reactors And Animatronics

Status
Not open for further replies.
Here's the second half-

//
// Nunchuck functions
//

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

// 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,
// returns 1 on successful read. returns 0 on failure
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[cnt] = 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[0];
int joy_y_axis = nunchuck_buf[1];
int accel_x_axis = nunchuck_buf[2]; // * 2 * 2;
int accel_y_axis = nunchuck_buf[3]; // * 2 * 2;
int accel_z_axis = nunchuck_buf[4]; // * 2 * 2;

int z_button = 0;
int c_button = 0;

// byte nunchuck_buf[5] 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[5]
if ((nunchuck_buf[5] >> 0) & 1)
z_button = 1;
if ((nunchuck_buf[5] >> 1) & 1)
c_button = 1;

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

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

if ((nunchuck_buf[5] >> 6) & 1)
accel_z_axis += 2;
if ((nunchuck_buf[5] >> 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;
}

// returns zbutton state: 1=pressed, 0=notpressed
int nunchuck_zbutton()
{
return ((nunchuck_buf[5] >> 0) & 1) ? 0 : 1; // voodoo
}

// returns zbutton state: 1=pressed, 0=notpressed
int nunchuck_cbutton()
{
return ((nunchuck_buf[5] >> 1) & 1) ? 0 : 1; // voodoo
}

// returns value of x-axis joystick
int nunchuck_joyx()
{
return nunchuck_buf[0];
}

// returns value of y-axis joystick
int nunchuck_joyy()
{
return nunchuck_buf[1];
}

// returns value of x-axis accelerometer
int nunchuck_accelx()
{
return nunchuck_buf[2]; // FIXME: this leaves out 2-bits of the data
}

// returns value of y-axis accelerometer
int nunchuck_accely()
{
return nunchuck_buf[3]; // FIXME: this leaves out 2-bits of the data
}

// returns value of z-axis accelerometer
int nunchuck_accelz()
{
return nunchuck_buf[4]; // FIXME: this leaves out 2-bits of the data
}


As for the Wave shield and adding sound effects, there's a great tutorial with lots of different code examples for the Wave shield here:
Audio Shield for Arduino

I'm sure there will be tons of questions so fire away and I'll help out as best as I can!
 
Last edited by a moderator:
I just picked up a couple of new microcontrollers so I should have a new super small board ready to go pretty soon. I'm designing it so that it will be able to drive up to six servos or a combination of servos/outputs as well as wireless capability. I might even add an onboard charging circuit (USB powered) for the single cell LiPo that powers the board. You'll be able to connect anything from switches to bend sensors to a Wii nunchuck as input devices.

Stay tuned...
 
Arduino Tutorial

Say, thanks for pointing me / us to that Arduino Tutorial (plus the related links)! That really cleared up a lot of things in my head about how controllers are used with basic electronics.

I need to learn about the various servos and switches out there and how to incorporate them into a costume. But that's some terrific info for me to start off with. Looks like I need to dig up $65 for that Arduino Starter Pack!
 
I just picked up the rest of the electronics I needed so I should have pics up late tonight of the new controller boards!
 
So here you go- this is just the first prototype using a hand cut PCB. Everything appears to be working just fine! Code uploaded no problem and the charging circuit is doing its job. I haven't yet tried the wireless so as soon as I can make another board I'll try to link them together- should be fun. I'm going to change a few things already- move some of the connectors around to make them more accessible, maybe drill some mounting holes, etc.

ServoBoardTop.jpg

ServoBoardWireless.jpg

ServoBoardChargingLiPo.jpg

ServoBoardBottom.jpg
 
Just finished the new board design- I'll be sending it off for production. Woohoo! I changed things around a bit to make all the connections easier to access and I added some mounting holes. It's only a tiny bit bigger than the proto. I figure I'm going to make ten boards in the first batch. It's looking like pricing will be $90 for the assembled and programmed board with a single cell LiPo battery. Can't wait to get it!

I'll also be making some adapter boards that will plug into one of the output sockets that have transistors to handle higher power loads like motors and high power LEDs.

ServoV1.jpg
 
And here's the board for the MkII reactor. This has 24 PLCC2 LEDs so it should be pretty bright based on my latest tests.

LEDBoardPLCC2v2.jpg
 
Boards are in! Here's the arc reactor board-
LEDboardV2lit.jpg

LEDboardV2populated.jpg


And here's the bare servo controller board- I should have this soldered up pretty soon.
ServoBoardPCB.jpg

ServoBoards.jpg
 
So here's what my final controller board looks like- you can clearly see the LiPo charging circuit and all the inputs/outputs. The finished board measures just under 2.25" x 1.75".
ServoBoardFinished1.jpg


Here's what it looks like with the wireless radio installed in its socket- it can also be connected with a cable.
ServoBoardFinished2.jpg

ServoBoardFinished.jpg


Now I'm working on the transistor adapter board- this will allow you to connect higher current devices like DC motors or high power LEDs. It connects to digital output pins 10-13. It measures .75" x 1.125".
TransistorBoardv20-1.jpg
 
My brain just fried from the technical data alone LOL. I wish I had this kind of knowledge but I only got as far as making a lie dector in science class.
 
Don't worry guys- I'll have a complete tutorial done up as soon as I make my prototype transistor board. I should have my little transistors this week. Once I'm finished people will see just how easy it is to use this and add some animatronics to your costumes.
 
Don't worry guys- I'll have a complete tutorial done up as soon as I make my prototype transistor board. I should have my little transistors this week. Once I'm finished people will see just how easy it is to use this and add some animatronics to your costumes.

Sounds, and looks amazing!! I can't wait to see more!
:D
 
Here's what the prototype transistor boards look like. I decided to go ahead and make two prototypes -one that is directly socketed to the controller and one that will connect with a cable. I'm starting to lean toward the cable connected version as I'm not really liking the way the socketed version sticks out. In the tutorial I'll also show how to build another version that can handle up to 5 Amp loads.

TransistorBoards.jpg

TransistorBoardSocketed.jpg
 
Here's the latest video of the Iron Man hand repulsor using the controller and a bend sensor.

I'm sooo close to getting the tutorial done.... any day now!
 
Last edited by a moderator:
Status
Not open for further replies.
Back
Top