Joystick was not declared in this scope error

Hi, I am brand new to Arduino. I have downloaded a library and sketch but keep getting this error and don't know where to start to fix the issue any help would be appreciated.

Arduino: 1.8.10 (Windows 10), Board: "Arduino/Genuino Micro"

C:\Users\Joe\AppData\Local\Temp\arduino_modified_sketch_210299\ANALOG_EBRAKE.ino: In function 'void setup()':

ANALOG_EBRAKE:14:4: error: 'Joystick' was not declared in this scope

Joystick.begin();}

^~~~~~~~

C:\Users\Joe\AppData\Local\Temp\arduino_modified_sketch_210299\ANALOG_EBRAKE.ino:14:4: note: suggested alternative: 'Joystick_'

Joystick.begin();}

^~~~~~~~

Joystick_

C:\Users\Joe\AppData\Local\Temp\arduino_modified_sketch_210299\ANALOG_EBRAKE.ino: In function 'void loop()':

ANALOG_EBRAKE:22:2: error: 'Joystick' was not declared in this scope

{Joystick.setThrottle(mapped);}}

^~~~~~~~

C:\Users\Joe\AppData\Local\Temp\arduino_modified_sketch_210299\ANALOG_EBRAKE.ino:22:2: note: suggested alternative: 'Joystick_'

{Joystick.setThrottle(mapped);}}

^~~~~~~~

Joystick_

Multiple libraries were found for "Joystick.h"
Used: E:\Arduino\libraries\Joystick
exit status 1
'Joystick' was not declared in this scope

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

// Analog eBrake-Handbrake
// PIN A0 to 10k pot output - Throttle Axis
// Use with Arduino ProMicro.
// Tested and working in DiRT RALLY + ASSETTO CORSA
// by AMSTUDIO
// 20.1.2017

#include <Joystick.h>

void setup()

{pinMode(A0, INPUT);
Joystick.begin();}

const int pinToButtonMap = A0;

void loop()

{int pot = analogRead(A0);
int mapped = map(pot,0,1023,0,255);
{Joystick.setThrottle(mapped);}}

Read forum rules

Provide details about your set up and which joystick library you use. look at their examples (your are likely missing creating the instance)

Please correct your post above and add code tags around your code:
[code]`` [color=blue]// your code is here[/color] ``[/code].

It should look like this:// your code is here
(Also press ctrl-T (PC) or cmd-T (Mac) in the IDE before copying to indent your code properly)

Add this line at the beginning of your code, before setup:

#include <Joystick.h>

lesept:
Add this line at the beginning of your code, before setup:

#include <Joystick.h>

It's there :wink:

But OP did not create an object of Joystick.

#include <Joystick.h>

Joystick_ Joystick(JOYSTICK_DEFAULT_REPORT_ID, 
  JOYSTICK_TYPE_MULTI_AXIS, 4, 0,
  false, false, false, false, false, false,
  false, false, true, true, true);


void setup()
...
...

Above copied from the DrivingControllerTest.ino example.

Seems like a recent hot topic - is this a class assignment?

sterretje:
But OP did not create an object of Joystick.

This exact same problem came up a few weeks ago.

The online tutorial involved provides its own joystick library, which instantiates the required Joystick object by itself.

Presumably the OP is using a different joystick library.

Thank you everyone. I was using the supplied Joystick library however when I placed it into my libraries folder it replaced an existing library, After I deleted the Joystick folder and moved over a fresh copy of the supplied library everything worked.