6 Shot Arduino Rubber Band Turret (Wii Nunchuck + Arduino)
by LosAlfajores in Circuits > Arduino
9484 Views, 57 Favorites, 0 Comments
6 Shot Arduino Rubber Band Turret (Wii Nunchuck + Arduino)
![DSCN0148.JPG](/proxy/?url=https://content.instructables.com/F7L/CJE6/HJAHP30I/F7LCJE6HJAHP30I.jpg&filename=DSCN0148.JPG)
![DSCN0121.JPG](/proxy/?url=https://content.instructables.com/F9W/E01M/HJAHP31X/F9WE01MHJAHP31X.jpg&filename=DSCN0121.JPG)
![DSCN0122.JPG](/proxy/?url=https://content.instructables.com/FOA/X0RK/HJAHP31V/FOAX0RKHJAHP31V.jpg&filename=DSCN0122.JPG)
![DSCN0123.JPG](/proxy/?url=https://content.instructables.com/FXT/NCYA/HJAHP31U/FXTNCYAHJAHP31U.jpg&filename=DSCN0123.JPG)
![DSCN0125.JPG](/proxy/?url=https://content.instructables.com/F74/3XNT/HJAHP31P/F743XNTHJAHP31P.jpg&filename=DSCN0125.JPG)
![DSCN0128.JPG](/proxy/?url=https://content.instructables.com/FP5/V45B/HJAHP31I/FP5V45BHJAHP31I.jpg&filename=DSCN0128.JPG)
![DSCN0129.JPG](/proxy/?url=https://content.instructables.com/FTT/1CPO/HJAHP31G/FTT1CPOHJAHP31G.jpg&filename=DSCN0129.JPG)
![DSCN0144.JPG](/proxy/?url=https://content.instructables.com/FI6/HQEU/HJAHP30R/FI6HQEUHJAHP30R.jpg&filename=DSCN0144.JPG)
![DSCN0147.JPG](/proxy/?url=https://content.instructables.com/FL1/9MZI/HJAHP30M/FL19MZIHJAHP30M.jpg&filename=DSCN0147.JPG)
![DSCN0146.JPG](/proxy/?url=https://content.instructables.com/FYB/JC4D/HJAHP30N/FYBJC4DHJAHP30N.jpg&filename=DSCN0146.JPG)
![DSCN0150.JPG](/proxy/?url=https://content.instructables.com/F42/8GG8/HJAHP30F/F428GG8HJAHP30F.jpg&filename=DSCN0150.JPG)
My intentions with this Instructable are more along the idea of giving other people a project idea, not so much laying out how exactly to do it, so bear with me, please =D
All credit goes to britknight for the idea (https://www.instructables.com/id/Wiichuck-Controlled-Turret/#step1).
I saw yours, was inspired, and thought I'd share what I did!
NOTE: I didn't have much time to put this Instructable together, and I won't have access to a computer until July 2015, so if you post questions, just know I won't be able to answer. =)
Thanks!
Materials
![DSCN0128.JPG](/proxy/?url=https://content.instructables.com/FP5/V45B/HJAHP31I/FP5V45BHJAHP31I.jpg&filename=DSCN0128.JPG)
I used:
Three hobby servos (all continuous rotation - any brand)
10 x 10" plexiglass sheet
One 12 x 8" Lexan sheet
About 2' of 1 x 1 x 1/16" Aluminum L-Bracket
About 1' of 3/4" x 3/4" x 1/16" Aluminum L-Bracket
A bunch of 6-32 size cap head screws and nuts
An Arduino Uno R3
A half size solderless breadboard and jumpers
A Wii Nunchuck
A WiiChuck adapter
A 6V power source (I use a 4 AA battery pack)
Really, get creative with materials! I was using scraps from the high school robotics workshop I mentor at, so there is definitely room for improvement on the materials side of things!
The Mechanical
![DSCN0123.JPG](/proxy/?url=https://content.instructables.com/FXT/NCYA/HJAHP31U/FXTNCYAHJAHP31U.jpg&filename=DSCN0123.JPG)
![DSCN0124.JPG](/proxy/?url=https://content.instructables.com/F1A/D4VI/HJAHP31Q/F1AD4VIHJAHP31Q.jpg&filename=DSCN0124.JPG)
![DSCN0131.JPG](/proxy/?url=https://content.instructables.com/FZA/CZGU/HJAHP31D/FZACZGUHJAHP31D.jpg&filename=DSCN0131.JPG)
![DSCN0132.JPG](/proxy/?url=https://content.instructables.com/FX5/LLCR/HJAHP31A/FX5LLCRHJAHP31A.jpg&filename=DSCN0132.JPG)
![DSCN0133.JPG](/proxy/?url=https://content.instructables.com/F6X/UD5A/HJAHP318/F6XUD5AHJAHP318.jpg&filename=DSCN0133.JPG)
![DSCN0135.JPG](/proxy/?url=https://content.instructables.com/F26/6GMQ/HJAHP316/F266GMQHJAHP316.jpg&filename=DSCN0135.JPG)
![DSCN0136.JPG](/proxy/?url=https://content.instructables.com/FJG/OTJI/HJAHP315/FJGOTJIHJAHP315.jpg&filename=DSCN0136.JPG)
![DSCN0138.JPG](/proxy/?url=https://content.instructables.com/FM7/E5GR/HJAHP313/FM7E5GRHJAHP313.jpg&filename=DSCN0138.JPG)
![DSCN0142.JPG](/proxy/?url=https://content.instructables.com/F1G/GZRS/HJAHP30Z/F1GGZRSHJAHP30Z.jpg&filename=DSCN0142.JPG)
![DSCN0143.JPG](/proxy/?url=https://content.instructables.com/FO6/9A23/HJAHP30V/FO69A23HJAHP30V.jpg&filename=DSCN0143.JPG)
Have a nice, solid base that is off the ground far enough that a servo will be able to attach to it and not hit the ground.
Mount the Left-Right servo smack dab in the middle!
You can see here how I used a trapezoidal shape for the vertical aiming. Really, it just makes it look cooler!
A problem I had was with the Lexan that the Up-Down servo attached to. If you make it too long, the servo will struggle to adjust your turret.
For the "barrel" itself, just make it look cool! The only functional pieces are where the firing servo attaches, and where the trapezoid connects. My advice, mount it so the center of gravity lies right over the Left-Right axis of rotation.
The Electrical
![DSCN0125.JPG](/proxy/?url=https://content.instructables.com/F74/3XNT/HJAHP31P/F743XNTHJAHP31P.jpg&filename=DSCN0125.JPG)
![DSCN0126.JPG](/proxy/?url=https://content.instructables.com/FZZ/KQFP/HJAHP31M/FZZKQFPHJAHP31M.jpg&filename=DSCN0126.JPG)
![DSCN0133.JPG](/proxy/?url=https://content.instructables.com/F6X/UD5A/HJAHP318/F6XUD5AHJAHP318.jpg&filename=DSCN0133.JPG)
![DSCN0137.JPG](/proxy/?url=https://content.instructables.com/FDE/PDGL/HJAHP314/FDEPDGLHJAHP314.jpg&filename=DSCN0137.JPG)
![DSCN0142.JPG](/proxy/?url=https://content.instructables.com/F1G/GZRS/HJAHP30Z/F1GGZRSHJAHP30Z.jpg&filename=DSCN0142.JPG)
I used the following pinout:
Pin 11: firing servo
Pin 10: Up-Down servo
Pin 9: Left-Right servo
Note for the firing servo: try to position it so it has a small amount of creep that counter-opposes the rubber bands.
The Software
![arduino_logo.jpg](/proxy/?url=https://content.instructables.com/FCA/3HXA/HJAHP3CN/FCA3HXAHJAHP3CN.jpg&filename=arduino_logo.jpg)
Now for the real fun: I2C communication!
Wii Nunchuks communicate through a language called I2C, which isn't insanely complicated, but we have an Arduino library to deal with that, the Wire library.
Here is my code, make what you will of it!
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[
#include //include the Wire library
#include
Servo LR; //servo for Left-Right movement
Servo UD; //servo for Up-Down movement
Servo bang; //servo for shooting rubber bands
char nunchuck = 0xA4 >> 1; //sets nunchuck address as 0xA4 (operationally 0x52)
uint8_t nunData[6]; //for storing data
int chunk; //for keeping track of the byte size chunks of data
int joyX;
int joyY;
int accelX; //make sure to add two bits because of the nunchuck's packaging protocol
int accelY;
int accelZ;
byte Zbutt; //isolates last bit of numData[5]
byte Cbutt;
void setup() {
LR.attach(9);
UD.attach(10);
bang.attach(11);
Serial.begin(19200);
Wire.begin(); //starts I2C communication
initialize(); //sets up the nunchuck
delay(100);
}
void initialize() {
Wire.beginTransmission (0x52); // transmit to device 0x52
Wire.send (0x40); // sends memory address
Wire.send (0x00); // sends sent a zero.
Wire.endTransmission (); // stop transmitting
}
void loop() {
Wire.requestFrom(nunchuck, 6); //send me that data!
chunk = 0;
while(Wire.available()) { //while there is data to send
nunData[chunk] = decode(Wire.receive()); //stores data to value 'chunk' of nunData, as well as decodes it
chunk++;
}
makeVars();
convert(); //package the sensor data
delay(50);
}
void convert() { //tells nunchuck to "package" the sensor data
Wire.beginTransmission(nunchuck); //tell nunchuck to listen
Wire.send(0x00); //sends zero
Wire.endTransmission(); //STOP
}
void makeVars() {
int joyX = nunData[0];
int joyY = nunData[1];
int accelX = nunData[2] * 2 * 2; //make sure to add two bits because of the nunchuck's packaging protocol
int accelY = nunData[3] * 2 * 2;
int accelZ = nunData[4] * 2 * 2;
byte Zbutt = (nunData[5] >> 0) & 1; //isolates last bit of numData[5]
byte Cbutt = (nunData[5] >> 1) & 1;
accelX = accelX + (nunData[5] >> 2) + 2 * (nunData[5] >> 3); //adds the two missing bits to each accel value (missing bits found in 6th Byte)
accelY = accelY + (nunData[5] >> 4) + 2 * (nunData[5] >> 5);
accelZ = accelZ + (nunData[5] >> 6) + 2 * (nunData[5] >> 7);
int horiz = map(joyX, 23, 230, 102, 78); //makes it so there is a small area in the middle where the joystick won't actuate anything (X direction)
if (abs(horiz - 90) <= 2) {
horiz = 90;
}
else if (horiz > 90) {
horiz -= 2;
}
else if (horiz < 90) {
horiz += 2;
}
int vert = map(joyY, 28, 231, 80, 100); //makes it so there is a small area in the middle where the joystick won't actuate anything (Y direction)
if (abs(vert - 90) <= 2) {
vert = 90;
}
else if (vert > 90) {
vert -= 2;
}
else if (vert < 90) {
vert += 2;
}
int shoot = 90; //creates shooting servo value
if ((Zbutt == 0) && (Cbutt != 0)) { //if Z is pressed, rotate shooting forward servo slowly
shoot = 95;
}
if ((Cbutt == 0) && (Zbutt != 0)) { //if C is pressed, rotate shooting backward servo quickly
shoot = 82;
}
LR.send(horiz); //send all the servo values
UD.send(vert);
bang.send(shoot);
}
char decode (byte x) { //decodes sensor value (referred to by an earlier statement)
x = (x ^ 0x17) + 0x17; //I have no idea what this means...
return x;
}
]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]
Let's Play!
![DSCN0150.JPG](/proxy/?url=https://content.instructables.com/F42/8GG8/HJAHP30F/F428GG8HJAHP30F.jpg&filename=DSCN0150.JPG)
Yaaaaaaaay.