Aren't you forgetting to create a joystick object? Look at the examples to see how to use the library.
Object declaration:
Joystick_ Joystick;
Here is your code with the joystick object declared and code formatted with the IDE tool, autoformat (ctrl-t or Tools, Auto Format). It compiles with no errors or warnings. It is, however, untested as I do not have a Leo.
#include <Joystick.h>
Joystick_ Joystick; // ******** added declaration
void setup()
{
pinMode(A3, INPUT); // ************ unnecessary as the pin defaults to input
Joystick.begin();
}
const int pinToButtonMap = A3; // *********** not used, why bother
void loop()
{
int pot = analogRead(A3);
int mapped = map(pot, 525, 870, 0, 255);
{
Joystick.setThrottle(mapped);
}
}
groundFungus:
Aren't you forgetting to create a joystick object? Look at the examples to see how to use the library.
Object declaration:
Joystick_ Joystick;
Here is your code with the joystick object declared and code formatted with the IDE tool, autoformat (ctrl-t or Tools, Auto Format). It compiles with no errors or warnings. It is, however, untested as I do not have a Leo.
#include <Joystick.h>
Joystick_ Joystick; // ******** added declaration
void setup()
{
pinMode(A3, INPUT); // ************ unnecessary as the pin defaults to input
Joystick.begin();
}
const int pinToButtonMap = A3; // *********** not used, why bother
void loop()
{
int pot = analogRead(A3);
int mapped = map(pot, 525, 870, 0, 255);
{
Joystick.setThrottle(mapped);
}
}
Thanks for that I have tried but when I compile it I get the following error
Arduino: 1.8.14 Hourly Build 2021/01/29 11:33 (Windows 10), Board: "Arduino Leonardo"
ANALOG_EBRAKE:3:1: error: 'Joystick_' does not name a type; did you mean 'Joystick'?
Joystick_ Joystick; // ******** added declaration
^~~~~~~~~
Joystick
R:\Mark\new gaming sim pc\handbrake mod\Analog-E-Brake-master (1)\Analog-E-Brake-master\ANALOG_EBRAKE\ANALOG_EBRAKE.ino: In function 'void setup()':
ANALOG_EBRAKE:10:12: error: expected unqualified-id before '.' token
Joystick.begin();
^
R:\Mark\new gaming sim pc\handbrake mod\Analog-E-Brake-master (1)\Analog-E-Brake-master\ANALOG_EBRAKE\ANALOG_EBRAKE.ino: In function 'void loop()':
ANALOG_EBRAKE:20:15: error: expected unqualified-id before '.' token
Joystick.setThrottle(mapped);
^
exit status 1
'Joystick_' does not name a type; did you mean 'Joystick'?
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.