'testAutoSendMode' was not declared in this scope

Hi all, i am trying to verify some script and it keeps coming up with this error message: 'testAutoSendMode' was not declared in this scope. Can someone please help

Setchy95:
Hi all, i am trying to verify some script and it keeps coming up with this error message: 'testAutoSendMode' was not declared in this scope. Can someone please help

By "script", do you mean an Arduino sketch?

Perhaps you should post the code. No one can really help based on what you've said so far. Sounds like a call to a function that doesn't exist. A library missing maybe?

Yes sorry i meant sketch.

Here is the sketch.

#include <Joystick.h>
#include <USBAPI.h>

// Program used to test the USB Joystick object on the
// Arduino Leonardo or Arduino Micro.
//
// Matthew Heironimus
// 2015-03-28
// Updated on 2015-11-18 to use the new Joystick library written for version 1.6.6.
//------------------------------------------------------------

// Set to true to test "Auto Send" mode or false to test "Manual Send" mode.
//const bool testAutoSendMode = true;
const bool testAutoSendMode = false;

const unsigned long gcCycleDelta = 1000;
const unsigned long gcAnalogDelta = 25;
const unsigned long gcButtonDelta = 500;
unsigned long gNextTime = 0;
unsigned int gCurrentStep = 0;

void testSingleButtonPush(unsigned int button)
{
if (button > 0)
{
Joystick.releaseButton(button - 1);
}
if (button < 32)
{
Joystick.pressButton(button);
}
}

void testMultiButtonPush(unsigned int currentStep)
{
for (int button = 0; button < 32; button++)
{
if ((currentStep == 0) || (currentStep == 2))
{
if ((button % 2) == 0)
{
Joystick.pressButton(button);
} else if (currentStep != 2)
{
Joystick.releaseButton(button);
}
} // if ((currentStep == 0) || (currentStep == 2))
if ((currentStep == 1) || (currentStep == 2))
{
if ((button % 2) != 0)
{
Joystick.pressButton(button);
} else if (currentStep != 2)
{
Joystick.releaseButton(button);
}
} // if ((currentStep == 1) || (currentStep == 2))
if (currentStep == 3)
{
Joystick.releaseButton(button);
} // if (currentStep == 3)
} // for (int button = 0; button < 32; button++)
}

void testXYAxis(unsigned int currentStep)
{
if (currentStep < 256)
{
Joystick.setXAxis(currentStep - 127);
Joystick.setYAxis(-127);
}
else if (currentStep < 512)
{
Joystick.setYAxis(currentStep - 256 - 127);
}
else if (currentStep < 768)
{
Joystick.setXAxis(128 - (currentStep - 512));
}
else if (currentStep < 1024)
{
Joystick.setYAxis(128 - (currentStep - 768));
}
else if (currentStep < 1024 + 128)
{
Joystick.setXAxis(currentStep - 1024 - 127);
Joystick.setYAxis(currentStep - 1024 - 127);
}
}

void testZAxis(unsigned int currentStep)
{
if (currentStep < 128)
{
Joystick.setZAxis(-currentStep);
}
else if (currentStep < 256 + 128)
{
Joystick.setZAxis(currentStep - 128 - 127);
}
else if (currentStep < 256 + 128 + 127)
{
Joystick.setZAxis(127 - (currentStep - 383));
}
}

void testHatSwitch(unsigned int currentStep)
{
if (currentStep < 8)
{
Joystick.setHatSwitch(0, currentStep * 45);
}
else if (currentStep == 8)
{
Joystick.setHatSwitch(0, -1);
}
else if (currentStep < 17)
{
Joystick.setHatSwitch(1, (currentStep - 9) * 45);
}
else if (currentStep == 17)
{
Joystick.setHatSwitch(1, -1);
}
else if (currentStep == 18)
{
Joystick.setHatSwitch(0, 0);
Joystick.setHatSwitch(1, 0);
}
else if (currentStep < 27)
{
Joystick.setHatSwitch(0, (currentStep - 18) * 45);
Joystick.setHatSwitch(1, (8 - (currentStep - 18)) * 45);
}
else if (currentStep == 27)
{
Joystick.setHatSwitch(0, -1);
Joystick.setHatSwitch(1, -1);
}
}

void testThrottleRudder(unsigned int value)
{
Joystick.setThrottle(value);
Joystick.setRudder(255 - value);
}

void testXYAxisRotation(unsigned int degree)
{
Joystick.setXAxisRotation(degree);
Joystick.setYAxisRotation(360 - degree);
}

void setup() {
if (testAutoSendMode)
{
Joystick.begin();
}
else
{
Joystick.begin(false);
}

pinMode(A0, INPUT_PULLUP);
pinMode(13, OUTPUT);
}

void loop() {

// System Disabled
if (digitalRead(A0) != 0)
{
digitalWrite(13, 0);
return;
}

// Turn indicator light on.
digitalWrite(13, 1);

if (millis() >= gNextTime)
{

if (gCurrentStep < 33)
{
gNextTime = millis() + gcButtonDelta;
testSingleButtonPush(gCurrentStep);
}
else if (gCurrentStep < 37)
{
gNextTime = millis() + gcButtonDelta;
testMultiButtonPush(gCurrentStep - 33);
}
else if (gCurrentStep < (37 + 256))
{
gNextTime = millis() + gcAnalogDelta;
testThrottleRudder(gCurrentStep - 37);
}
else if (gCurrentStep < (37 + 256 + 1024 + 128))
{
gNextTime = millis() + gcAnalogDelta;
testXYAxis(gCurrentStep - (37 + 256));
}
else if (gCurrentStep < (37 + 256 + 1024 + 128 + 510))
{
gNextTime = millis() + gcAnalogDelta;
testZAxis(gCurrentStep - (37 + 256 + 1024 + 128));
}
else if (gCurrentStep < (37 + 256 + 1024 + 128 + 510 + 28))
{
gNextTime = millis() + gcButtonDelta;
testHatSwitch(gCurrentStep - (37 + 256 + 1024 + 128 + 510));
}
else if (gCurrentStep < (37 + 256 + 1024 + 128 + 510 + 28 + 360))
{
gNextTime = millis() + gcAnalogDelta;
testXYAxisRotation(gCurrentStep - (37 + 256 + 1024 + 128 + 510 + 28));
}

if (testAutoSendMode == false)
{
Joystick.sendState();
}

gCurrentStep++;
if (gCurrentStep == (37 + 256 + 1024 + 128 + 510 + 28 + 360))
{
gNextTime = millis() + gcCycleDelta;
gCurrentStep = 0;
}
}
}

You can't post your code inline like that. It must be placed between code tags. Besides other considerations, part of your code has turned into 'smilies', making it unreadable.

You really should have read the How to use this forum - please read post at the top of the index page and How to use this forum before posting.

ie Your code and any error messages should always be placed between code tags. Posting it inline as you have done makes it much harder to read or copy and paste for diagnosis.

It's still not too late to edit your post and do this. You'll make potential helpers much happier. :slight_smile:

And you'd better post your error message as well, (also between code tags).
'testAutoSendMode' has been declared globally, so it shouldn't throw that error, as far as I can see.
Which joystick library are you using? A link?