Error 'Joystick' was not declared in this scope

Hello, I came with the first project, I took the initiative to create an analog hand brake with the following Pro Micro ATmega32U4 and KY 024. This reference base was DIY Analog USB Handbrake - YouTube. I took this library GitHub - MHeironimus/ArduinoJoystickLibrary: An Arduino library that adds one or more joysticks to the list of HID devices an Arduino Leonardo or Arduino Micro can support. and put the folder inside libraries and the code used is this even informed in the video

#include <Joystick.h>

void setup() 

{pinMode(A3, INPUT);

   Joystick.begin();}

const int pinToButtonMap = A3;   

void loop() 

{int pot = analogRead(A3);
int mapped = map(pot,525,870,0,255);
{Joystick.setThrottle(mapped);}}

previously I took another code and put it in and just changed what it represented in the other video, it worked but when I put it to test on the game controller it didn't come out of 43% nor did it show any sign of functioning

#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);}}

I see that it didn't work, I try to use the joystick folder provided by GitHub - MHeironimus/ArduinoJoystickLibrary: An Arduino library that adds one or more joysticks to the list of HID devices an Arduino Leonardo or Arduino Micro can support. and enter this error

Arduino: 1.8.13 (Windows 10), Board: "Arduino Micro"

C: \ Users \ THMN \ Desktop \ sketch_oct09c \ sketch_oct09c.ino: In function 'void setup ()':

sketch_oct09c: 7: 4: error: 'Joystick' was not declared in this scope

Joystick.begin ();}

^ ~~~~~~~

C: \ Users \ THMN \ Desktop \ sketch_oct09c \ sketch_oct09c.ino: 7: 4: note: suggested alternative: 'Joystick_'

Joystick.begin ();}

^ ~~~~~~~

Joystick_

C: \ Users \ THMN \ Desktop \ sketch_oct09c \ sketch_oct09c.ino: In function 'void loop ()':

sketch_oct09c: 15: 2: error: 'Joystick' was not declared in this scope

{Joystick.setThrottle (mapped);}}

^ ~~~~~~~

C: \ Users \ THMN \ Desktop \ sketch_oct09c \ sketch_oct09c.ino: 15: 2: note: suggested alternative: 'Joystick_'

{Joystick.setThrottle (mapped);}}

^ ~~~~~~~

Joystick_

Multiple libraries were found for "Joystick.h"

Used: E: \ Installed Programs \ Arduino \ libraries \ Joystick

Not used: C: \ Users \ THMN \ Documents \ Arduino \ libraries \ ArduinoJoystickLibrary-master

exit status 1

'Joystick' was not declared in this scope

This report would have more information with
"Show detailed output during compilation"
option can be activated in "File -> Preferences"

When the photos are a reference of the lights it looks like something has already been recorded, you would have to delete what was recorded or when you provide another code and load it performs the replacement of the old code by overwriting it

I hope I have described all the possible errors and information necessary for all of you to help me

Thank you very much in advance

That's because you've not declared any variable called "joystick".

Since that library comes with examples you should be able to figure out how to use it :slight_smile:

lthumnz:
Hello, I came with the first project, I took the initiative to create an analog hand brake with the following Pro Micro ATmega32U4 and KY 024. This reference base was https://www.youtube.com/watch?v=CaOAafB68SE. I took this library GitHub - MHeironimus/ArduinoJoystickLibrary: An Arduino library that adds one or more joysticks to the list of HID devices an Arduino Leonardo or Arduino Micro can support. and put the folder inside libraries and the code used is this even informed in the video

#include <Joystick.h>

void setup()

{pinMode(A3, INPUT);

Joystick.begin();}

const int pinToButtonMap = A3;

void loop()

{int pot = analogRead(A3);
int mapped = map(pot,525,870,0,255);
{Joystick.setThrottle(mapped);}}





previously I took another code and put it in and just changed what it represented in the other video, it worked but when I put it to test on the game controller it didn't come out of 43% nor did it show any sign of functioning




#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);}}





I see that it didn't work, I try to use the joystick folder provided by https://github.com/MHeironimus/ArduinoJoystickLibrary and enter this error

Arduino: 1.8.13 (Windows 10), Board: "Arduino Micro"



C: \ Users \ THMN \ Desktop \ sketch_oct09c \ sketch_oct09c.ino: In function 'void setup ()':

sketch_oct09c: 7: 4: error: 'Joystick' was not declared in this scope

Joystick.begin ();}

^ ~~~~~~~

C: \ Users \ THMN \ Desktop \ sketch_oct09c \ sketch_oct09c.ino: 7: 4: note: suggested alternative: 'Joystick_'

Joystick.begin ();}

^ ~~~~~~~

Joystick_

C: \ Users \ THMN \ Desktop \ sketch_oct09c \ sketch_oct09c.ino: In function 'void loop ()':

sketch_oct09c: 15: 2: error: 'Joystick' was not declared in this scope

{Joystick.setThrottle (mapped);}}

^ ~~~~~~~

C: \ Users \ THMN \ Desktop \ sketch_oct09c \ sketch_oct09c.ino: 15: 2: note: suggested alternative: 'Joystick_'

{Joystick.setThrottle (mapped);}}

^ ~~~~~~~

Joystick_

Multiple libraries were found for "Joystick.h"

Used: E: \ Installed Programs \ Arduino \ libraries \ Joystick

Not used: C: \ Users \ THMN \ Documents \ Arduino \ libraries \ ArduinoJoystickLibrary-master

exit status 1

'Joystick' was not declared in this scope



This report would have more information with
"Show detailed output during compilation"
option can be activated in "File -> Preferences"



When the photos are a reference of the lights it looks like something has already been recorded, you would have to delete what was recorded or when you provide another code and load it performs the replacement of the old code by overwriting it

I hope I have described all the possible errors and information necessary for all of you to help me


Thank you very much in advance

![ProMicro.jpg|748x1039](upload://6Kot5LrUiAs4moJOzGIPK73DLB8.jpeg)

![Ky024.jpg|889x1196](upload://bM1wq5R9Z82qvvRtdpKpc4pzrne.jpeg)

thank you very much for the answers, but I tried and tried and got to that point, where I also don't know what to do, some light or suggestion

03.jpg

03.jpg

I suggest that you go to you tube and do a search for joystick and Arduino, google is your friend. Paul McWorter teaches an Arduino course on you-tube, very informative, he has a few on joysticks ,one in particular he uses a joystick to control a servo motor. He also has a website called Toptechboy.com that shows the actual code written that could be cut and pasted.