I am trying to make a project where I use the Nunchuk data from the joystick and the accelerometer, at the moment I don't know what for but I am just trying to get the data feeding into the serial data in the IDE and am following this Youtube Tutorial and have fallen at the first hurdle pretty much. I have the adaptor, the nunchuk, the Mega and the code and files which I have extracted from https://github.com/infusion/Fritzing/tree/master/Nunchuk
Most likely the reason is I am using an Arduino Mega2560 instead of an Uno as is used on the tutorial, so the 4 pins from the Nunchuk to the Mega are a little awkward.
When compiling and uploading the code I got from the video, I get this error:
as a newcomer trying this project as the first step is very ambitious.
This is like you are able to ride a normal bike on the street and have quite some years of experience with that and some training for a 50 miles bike-trip.
And now you change to a BMX trying to do backflips in the half-pipe.
In the bike-example it is very clear: you gonna hurt yourself seriously.
You start with small hops over a two feet high ramp to get a "feeling" for:
how does the BMX-bike jump?
how do I have to position my body for a smooth landing.
how do I have to move my body and bike as a unit to gain some extra height when jumping over the ramp?
etc.
with programming an arduino there is danger to hurt yourself as long as you stay away from mains-voltage but you might not be able to analyse what is the bug?
So as some first steps
Take a look into this tutorial:
It is easy to understand and has a good mixture between explaining important concepts and example-codes to get you going. So give it a try and report your opinion about this tutorial.
I am trying to be ambitious I'm aware it's a tricky step but thought if I manage to do that then it will be a solid start to help future projects.
Thanks for the link and I am aware I need to learn the basics and I am by reading books and trying to understand all the functions, will read through your link now.
#if defined(__AVR_ATmega168__) || defined(__AVR_ATmega328P__) // Only Arduino UNO
/**
* Use normal analog ports as power supply, which is useful if you want to have all pins in a row
* Like for the famous WiiChuck adapter
* @see https://todbot.com/blog/2008/02/18/wiichuck-wii-nunchuck-adapter-available/
*/
static void nunchuk_init_power() {
// Add power supply for port C2 (GND) and C3 (PWR)
PORTC &= ~_BV(PORTC2);
PORTC |= _BV(PORTC3);
DDRC |= _BV(PORTC2) | _BV(PORTC3);
delay(100);
}
#endif
It looks like nunchuk_init_power() should be called only if you're using the adapter mentioned in the video, and I'm guessing that it is expected that the adapter is used with an Uno. You're using a mega, so if you want to use the adapter (and the pinout matches the Uno for the A4 and A5 pins, which I'm quite sure it does) you should be able to uncomment the #if defined(__AVR_ATmega168__) || defined(__AVR_ATmega328P__)
and #endif lines around static void nunchuk_init_power. If you don't want to use the adapter, I'd guess that you can just power the nunchuk from the 5v pin on the mega, though this isn't a great idea for a long-term setup.