in case anyone was wondering tonight I'm
sampling
corsair brown ale it is an English brown
ale
... from a brewery in Quebec
so today i'm going to be tinkering with
and experimenting with
these wii nunchuck controllers
these two i got quite some time ago at a
thrift store for a buck each
 I'm pretty confident that these are
both knockoffs or aftermarkets or
whatever
that one says intertek on it this one
says absolutely
nothing except for the usual warnings
so  the reason that
i grabbed these was that i know
originally i grabbed them just because
they've got some
neat little sensors and things in them
and then i spotted
these little breakout boards on ebay
which meet with the connector there's
two pins on top
and three on the bottom but only four of
them actually do anything
and that matches with that just like
that
so um with only four pins
and they're actually labeled on here
minus plus dc
so voltage data and clock
so that should be pretty straightforward
to uh to interface with
and i've already done a little bit of
looking and i know that there is an
arduino library or two
out there for this thing but before i
get to that
this has screws in it
obviously we're we're destined to take
it apart and just see what all is in
there
you wouldn't expect anything else of me
would you
well it seems to come apart just
kind of clam shelly where's the spudger
here
yeah so we got a top two little sides
circuit board a few wires what are there
five wires in there one of them's
obviously ground
and yeah we knew that there's five wires
down there okay
uh cap
that looks quite similar to the little
joystick modules that
you can commonly find on ebay
this kind of little modules well the
shaft's a little bit different
that one's got a narrower shaft on it
than that one
i wonder if they're all like that these
these have different potentiometers
now these ones all have a more sturdy
plastic
shaft on them yeah
so oh does this one click it does
okay but they are all pretty much
the same internally um
you've got two potentiometers this one
on the side here
for measuring that way this one for
measuring that way
and then there's a little clicky button
you can see it better on here
right there so five volts uh
ground x y and switch
so that's probably pretty similar on
this one
let's go deeper
so two buttons on the front there on
this little board here
and then oh hello there's some brain
boxing going on down there
i wasn't expecting all that so there's
two crystals
on here that one's a 16 meg and that
one's a four meg
there's quite a little um
mess of resistors there what the hell
are those guys doing
oh and there's another little chip
hiding underneath them too okay
so those are going to two different pads
so
hmm that looks pretty barge doesn't it
so and it's hiding a chip under it
labeled u4 then there's this main
chip here 5851l
qfp48
no idea and of course no idea what that
thing is
under that little blob there so
basically we seem to have
a microcontroller um
something a couple of crystals
another mystery chip under there
and another mystery bob chip on this
side
so whatever's going on they don't really
want us to know oh
we got a capacitor a few other
decoupling capacitors
oh whatever so that wasn't entirely
informative but i guess one of the
things that we
a couple of things we do know about it
or can infer about it
is that there is an accelerometer in
there
and there is some kind of a
microcontroller i tried to look up that
part number
and of course there's nothing
anywhere that i could find
okay so that goes back together fairly
straightforward
i think not that it matters that much
because i got two of them
and they weren't dirt cheap
so i think what i'm gonna do is try and
dig up a library and some sample code
and see if i can play with this
well this looks promising it says you
need a level shifter but
i've found other projects that say you
don't and this thing does run on 3.3
volts i'm going to try it without just
for the hell of it
it uses i2c which we saw earlier in the
data and clock
and sort of suspected that so that makes
it
pretty straightforward and easy to work
with so
you just connect it to the seo and sda
it it doesn't get much simpler than that
and i noticed that up earlier he was
talking about using level shifter but
down here he's not actually using one
so whatever then there's this library
this library here on this github i'll
put a link down below if
anybody wants to play with it and it
comes with a demo sketch which is the
same one that's in that
article so this one you need uh
processing
in order to talk to it and get it to
display its data
i don't have that and i don't feel like
setting it up but
i don't have to because he's broken out
what all the functions that the library
provides are
so i'm just going to take a few minutes
and go ahead and
get it to read all of those and i shall
be
back shortly alrighty here is that chunk
of code
that i've modified a little bit um
just created a serial begin and then
i've taken all of those functions from
that
web page and just
told it to serial print them so that we
can take a look at them
nice and easy let's throw that on to uh
some kind of an arduino board and hook
it up and see what happens
so here we have um all the different
columns
um the z button here
the c button and then for each
of the joystick x and y there's two
different numbers there's a raw
number here and then there's a kind of
filtered or processed number here
same for y so if i crank the joystick
to the left we see the y
change actually no
we see the x change don't we sure x
x raw and x change drastically crank it
to the right
that maxes it out up there the y
changes and down the y changes again
now then there's this angle one here
it is doing some weird math on
all on both axes of the joystick and
coming up with a number
i'll show you that a little bit more
friendly way later
um and here is the accelerator or the
accelerometer again
raw in x and processed in x raw in
y and processed in y and z
so if i twist my wrist around
see that changing and tilt it
and
what are these three directions here
there's that
oh there's that
and then there's this it's got to be an
easier way to see this
let's try the serial plotter although
it's showing
a whole bunch of different things
so let me just do the accelerometer
stuff again here's tilting it
up see that
changing and tilting it down
rotating it rolling it to the right
back to center and to the left and
center
and then rotating it this way
it doesn't seem to do as much anyway
here's the joystick
moving around see that and the buttons
i'm just going to take some of those
parameters out so we can see this a
little bit cleaner
okay so now all i have showing is the
joystick
x and x raw
y and y raw and the angle which is
calculated
out of that the documentation that i
found
says that it's done in radians so here
we go this is just the joystick
so if i go left
center right center
up center down
center so that should be pretty easy to
work with you'd think
let me just uh swap this out again and
just put the accelerometer stuff in here
and i think i'll just put the raw
accelerometer data in
x-raw y-raw and z-raw nothing else
i'm trying to hold this as steady as i
can right now
so if i do that
i twist it a little bit let me go back
to neutral again
so that looks like that one is changing
the red one
and if i twist my wrist this way that's
the blue one
and so i guess
how do i make that one go
that's the red one definitely
oh it's this way okay let me stabilize
again here
no that's the blue hmm
i don't know anyway they all do
something obviously
um this is a little bit twitchy for me
to interpret
so that's definitely that direction
and that's definitely that direction
so just for fun i uh found this other uh
other little project that also uses the
uh the nunchuck
this one's controlling servos which is
kind of cool
more background about this this guy
claims that it can
that the uh nunchuck can be connected to
5 volts
i'm still leaving mine connected at a
3.3 it seems to be working fine
this thing doesn't even use a nunchuck
library it just uses wire.h which is
the i2c library and the servo library
which is kind of slick and here is the
code that it
can't this little webpage came with
i'll link to that article too but here's
where it came from originally now then i
didn't write this and i haven't reverse
engineered it too much
okay so there is all the stuff on the
serial monitor
i can't remember what the
that's just a count okay that's the
joystick and the accelerometer and the
buttons
so again we'll push the buttons yeah
that works
move the joystick around
just will it swivel it around for the
accelerometer sure
okay interesting whatever but
let's look at what's happening in the
real world so if you remember
the two servos were mapped to the
joystick
that could come in handy
for driving some kind of a vehicle or a
robot or something
well i'm sure there is
more that can be done with these but
that i mean
now that we know how to read it
especially from the previous sketch
because i could re
using the library which makes more sense
to me because i can get numbers off
any of the functions that this thing
provides so it should be able to make it
do
make it control pretty much anything
right
that becomes the question what do i want
to control with these
hmm i don't know um
it'll probably show up again and again
when i just need a simple control
i i could use these joysticks too
but this is such a nice little ergonomic
little package
and two fire buttons even if i don't use
the accelerometers because they're
they seem a little twitchy um
i don't know uh what i want to be
weaving my hand around to make uh
make things happen the joystick seems
more intuitive to me
i don't know uh anyway you have any
ideas what i should do with this
they're just fun i think i'll look out
in the in the thrift stores for more of
these things especially if i can find
them for a buck
assuming thrift stores have survived the
you know uh
plague anyway uh thanks for watching uh
comments and questions and suggestions
down below in the comment section as
always
thanks for watching i'll talk to you
later
