Error in Program While Compiling for Arduino Leonardo

Hello Everyone,

I just need a help from you guys.

Here is the Sample code friends that I have been using for compiling. And the error I received was,

" C:\Program Files\Arduino\hardware\arduino\avr\cores\arduino\CDC.cpp:64:16: error: 'USBSetup' was not declared in this scope

bool CDC_Setup(USBSetup& setup)

^

exit status 1
Error compiling."

Any help would prove as boon for my project As its rather an important project that i've been working for my studies.

JoyState_t joySt;

// specify the digital pin number for each button
const int button1 = 2;
const int button2 = 4;
const int button3 = 7;
const int button4 = 8;
const int button5 = 9;
const int button6 = 10;

// mask value for each button
const int maskBtn1 = 1;
const int maskBtn2 = 2;
const int maskBtn3 = 4;
const int maskBtn4 = 8;
const int maskBtn5 = 16;
const int maskBtn6 = 32;

// specify analog pin number for each pot
const int steerPin = A0;
const int gasPin = A1;
const int brkPin = A2;

// special button used to temporarily
// suspend the flow of key and mouse data
// when pushing a sketch to the Arduino
const int programBtn = 12;

void setup() {
// initialize serial communication at 9600 bits per second
// The Leonardo board uses Serial1 to communicate via TTL (5V) serial on pins 0 (RX) and 1 (TX)
Serial1.begin(9600);

// initialize joystick
joySt.xAxis = 0;
joySt.yAxis = 0;
joySt.zAxis = 0;
joySt.xRotAxis = 0;
joySt.yRotAxis = 0;
joySt.zRotAxis = 0;
joySt.throttle = 0;
joySt.rudder = 0;
joySt.hatSw1 = 0;
joySt.hatSw2 = 0;
joySt.buttons = 0;

// set button pins as input with pullup enabled
pinMode(button1, INPUT_PULLUP);
pinMode(button2, INPUT_PULLUP);
pinMode(button3, INPUT_PULLUP);
pinMode(button4, INPUT_PULLUP);
pinMode(button5, INPUT_PULLUP);
pinMode(button6, INPUT_PULLUP);
pinMode(programBtn, INPUT_PULLUP);
}

void loop() {

// Windows sees our controller as a Joystick
// Steering is the X axis, Gas/Brake pedals are the Y axis
joySt.xAxis = map(analogRead(steerPin), 45, 1000, 0, 255);
int brkPed = map(analogRead(brkPin), 25, 1000, 0, 126);
int gasPed = map(analogRead(gasPin), 25, 1000, 127, 254);
// brake and gas pedals are combined into a single Y-axis
joySt.yAxis = 255 - (gasPed - brkPed);
// The state of all six buttons is stored in a single (bit-aligned) value
joySt.buttons = GetButtonsValue();

// finally, we send the "Joystick" data to the PC
Joystick.setState(&joySt);
if (digitalRead(programBtn) != HIGH) {
// if the program button is pushed, we slow the loop.
// This lets us push code to the Arduino
delay(250);
}
}

// check each button, if currently pushed "OR"
// that button's mask value with the return value
int GetButtonsValue(){
int returnVal = 0;
if (digitalRead(button1) != HIGH) {
returnVal = returnVal | maskBtn1;
}
if (digitalRead(button2) != HIGH) {
returnVal = returnVal | maskBtn2;
}
if (digitalRead(button3) != HIGH) {
returnVal = returnVal | maskBtn3;
}
if (digitalRead(button4) != HIGH) {
returnVal = returnVal | maskBtn4;
}
if (digitalRead(button5) != HIGH) {
returnVal = returnVal | maskBtn5;
}
if (digitalRead(button6) != HIGH) {
returnVal = returnVal | maskBtn6;
}
// returnVal represents
return returnVal;
}

Please help,
Regards.

Please modify your post and use the code button </>

so your code looks like this

and is easy to copy to a text editor. See How to use the Forum Your code is too long to study quickly without copying to a text editor.

…R