
I am trying to use the Arduino analog pins as digital inputs with the joystick sketch
- or -
Post a project like this3267
$
- Posted:
- Proposals: 6
- Remote
- #1312213
- Awarded
Electronics design, analog design, embedded coding ,PCB design and software(CCS,HTML,Javascipt, Java, Python,Matlab, PHP,Wordpress)

13504523291894867976818488594131224926





Description
Experience Level: Entry
General information for the business: Personal Project.
Kind of development: Customization of existing program
Description of requirements/functionality: I literally want to use the analog pins on the Arduino Leonardo as digital pins to increase the number of inputs so I can use more than 12 buttons with the joystick sketch. It looks like it should be simple to do so I am sure I am making some dumb mistake. Here is what I have, it is basically one of the example sketches with extra digital pins added.
#include
void setup() {
// Initialize Button Pins
pinMode(1, INPUT_PULLUP);
pinMode(2, INPUT_PULLUP);
pinMode(3, INPUT_PULLUP);
pinMode(4, INPUT_PULLUP);
pinMode(5, INPUT_PULLUP);
pinMode(6, INPUT_PULLUP);
pinMode(7, INPUT_PULLUP);
pinMode(8, INPUT_PULLUP);
pinMode(9, INPUT_PULLUP);
pinMode(10, INPUT_PULLUP);
pinMode(11, INPUT_PULLUP);
pinMode(12, INPUT_PULLUP);
pinMode(13, INPUT_PULLUP);
// Initialize Joystick Library
Joystick.begin();
}
// Constant that maps the phyical pin to the joystick button.
const int pinToButtonMap = 1;
// Last state of the button
int lastButtonState[13] = {0,0,0,0,0,0,0,0,0,0,0,0,0};
void loop()
And that is it, I am sure this is going to be easy for anyone familiar with this system to sort out. Thanking you in advance for your help. John Hyde.
Extra notes:
Kind of development: Customization of existing program
Description of requirements/functionality: I literally want to use the analog pins on the Arduino Leonardo as digital pins to increase the number of inputs so I can use more than 12 buttons with the joystick sketch. It looks like it should be simple to do so I am sure I am making some dumb mistake. Here is what I have, it is basically one of the example sketches with extra digital pins added.
#include
void setup() {
// Initialize Button Pins
pinMode(1, INPUT_PULLUP);
pinMode(2, INPUT_PULLUP);
pinMode(3, INPUT_PULLUP);
pinMode(4, INPUT_PULLUP);
pinMode(5, INPUT_PULLUP);
pinMode(6, INPUT_PULLUP);
pinMode(7, INPUT_PULLUP);
pinMode(8, INPUT_PULLUP);
pinMode(9, INPUT_PULLUP);
pinMode(10, INPUT_PULLUP);
pinMode(11, INPUT_PULLUP);
pinMode(12, INPUT_PULLUP);
pinMode(13, INPUT_PULLUP);
// Initialize Joystick Library
Joystick.begin();
}
// Constant that maps the phyical pin to the joystick button.
const int pinToButtonMap = 1;
// Last state of the button
int lastButtonState[13] = {0,0,0,0,0,0,0,0,0,0,0,0,0};
void loop()
And that is it, I am sure this is going to be easy for anyone familiar with this system to sort out. Thanking you in advance for your help. John Hyde.
Extra notes:

John H.
0% (0)Projects Completed
-
Freelancers worked with
-
Projects awarded
100%
Last project
16 Oct 2025
United Kingdom
New Proposal
Login to your account and send a proposal now to get this project.
Log inClarification Board Ask a Question
-
There are no clarification messages.
We collect cookies to enable the proper functioning and security of our website, and to enhance your experience. By clicking on 'Accept All Cookies', you consent to the use of these cookies. You can change your 'Cookies Settings' at any time. For more information, please read ourCookie Policy
Cookie Settings
Accept All Cookies