I'm trying to manipulate a byte in the WiiChuck demo program for the wiiChuck that's on todbot.com (I'm sure many are familiar with it).
The specific code that confuses me is this-
zbut = nunchuck_zbutton();
Serial.print("\tzbut: "); Serial.print((byte)zbut,DEC);
that code keeps looping around and it'll output in the serial monitor that zbut = 1 if it's held down, or a 0 if it's not.
first question: 'zbut' is not declared previously, the first instance is as shown here where it's set equal to nunchuck_zbutton(). Why is that? I would think we'd have to declare a data type before we just go stuffing something into a variable...
second question: Serial.print((byte)zbut,DEC);... why does it have to say 'byte' there?
third question: DEC... what's that mean?
fourth question (and the main one): I'm trying to make it so when I push the Z button once, it toggles whether or not sensor data from the accelerometer is being used. My code looks like this:
if ((byte)zbut = HIGH)
{
if (zButtonToggle = 1)
{
zButtonToggle = 0;
}
else
{
zButtonToggle = 1;
}
}
but I'm purely guessing on the condition of that first if() statement. I've tried just putting (zbut = 1) or (zbut = high) but nothing. I'm outputting zButtonToggle and watching it in the Serial Monitor along with zbut, and zbut works fine, but zButtonToggle does nothing. I'd sure appreciate it if someone could explain to me why that is. Thanks.