Wii Chuck Controlled Air-soft Gun Turret :D

3,453

19

14

Introduction: Wii Chuck Controlled Air-soft Gun Turret :D




Code  


#include
#include

/*
 * WiiChuck Turret --
*
* 2011 Luke Cudnik
*
*/

#include
#include "nunchuck_funcs.h"

int loop_cnt=0;
Servo s1;
Servo s2;
byte accx,accy,zbut,cbut;
int ledPin = 13;


void setup()
{
pinMode(11, OUTPUT);
Serial.begin(19200);
nunchuck_setpowerpins();
nunchuck_init(); // send the initilization handshake
s1.attach(6);
s2.attach(8);
Serial.print("WiiChuckDemo ready\n");
}

void loop()
{
if( loop_cnt > 100 ) { // every 100 msecs get new data
loop_cnt = 0;

nunchuck_get_data();

accx = nunchuck_joyx(); // ranges from approx 70 - 182
accy = nunchuck_joyy(); // ranges from approx 65 - 173
zbut = nunchuck_zbutton();
cbut = nunchuck_cbutton();

int ax= map(accx,30,230,1,180);
int ay= map(accy,30,230,1,180);
Serial.print("accx: ");
Serial.print((byte)accx,DEC);
Serial.print("\taccy: ");
Serial.print((byte)accy,DEC);
Serial.print("\tzbut: ");
Serial.print((byte)zbut,DEC);
Serial.print("\tcbut: ");
Serial.println((byte)cbut,DEC);
Serial.print("\ax: ");
Serial.println((byte)ax,DEC);
Serial.print("\ay: ");
Serial.println((byte)ay,DEC);
if (cbut ==1){
s1.write(90);
s2.write(90);
}
if (cbut == 0){
if((ax<80) or (ax>100)){
s1.write(ax);
}
else{
s1.write(90);
}
}
if (cbut == 0){
if((ay<80) or (ay>100)){
s2.write(ay);
}
else{
s2.write(90);
}
}
}
if (zbut == 1){
digitalWrite(11, HIGH);
}
if (zbut == 0){
digitalWrite(11, LOW);
}
loop_cnt++;
delay(1);
}

Make It Move Challenge

Participated in the
Make It Move Challenge

Microcontroller Contest

Participated in the
Microcontroller Contest

Be the First to Share

    Recommendations

    • Photography Challenge

      Photography Challenge
    • Raspberry Pi Contest

      Raspberry Pi Contest
    • One Board Contest

      One Board Contest

    14 Comments

    0
    vishalapr
    vishalapr

    10 years ago on Introduction

    WOHOHO this is amazing!Rated 4.5*
    Have a look at my entry for the contest!
    I voted for yrs and subscribed to you!!!

    0
    demonxkid
    demonxkid

    Reply 10 years ago on Introduction

    its clearly not done but thanks for your comment and support.
    it is wireless and tested by to 10 yrds but will probably work further bu i ran out of hallway XD

    0
    vishalapr
    vishalapr

    Reply 10 years ago on Introduction

    What do you mean "its clearly not done"??

    0
    demonxkid
    demonxkid

    Reply 10 years ago on Introduction

    oh sorry in this vid you cant see the arduino. i have jumpers going everywhere and as soon as my pcb's get here im making it all into a shield for the arduino. i also have a top cover for it to make it look more turrent-y . and i need to find a better power supply this thing EATS 9v batteries :D but once im done im turning this into a completed instructable

    0
    vishalapr
    vishalapr

    Reply 10 years ago on Introduction

    I noticed that but I still like the concept of this ible!
    Have a look at my ibles and vote for em' if u like em'

    0
    vishalapr
    vishalapr

    Reply 10 years ago on Introduction

    Yr welcome!And thanks from my side as for having a look at my ibles!

    WOOT! That thing is amazing!

    I was working on a similar project, I haven't allready started to write the code but I have done the PCB that works with an atmega328 (arduino bootloaded), the board is really small and single sided.

    Maybe we can work together to upgrade it?

    P.S. Sorry if my english is bad it's not my first language.

    0
    demonxkid
    demonxkid

    Reply 10 years ago on Introduction

    well we probably live really far apart and even then its hard for me to work on it cuz of school and work

    0
    THEORANGESNOWFROG
    THEORANGESNOWFROG

    Reply 10 years ago on Introduction

    Or I can just email you the board designs, I have completed an arduino sheild.

    0
    demonxkid
    demonxkid

    Reply 10 years ago on Introduction

    O.o could you really? that would be sweet. and i could help you with all the necessary code?

    0
    demonxkid
    demonxkid

    Reply 10 years ago on Introduction

    i tried making it its own board but im awful at elec. eng. :(