Arduino code help please

Hi all,

I finished 3d printing and building a sequential shifter found on thingyverse after receiving all the parts this weekend to complete it.

Shifter : https://www.thingiverse.com/thing:4557771/comments

Im a complete noob when it comes to arduinos. Ive opened the file that comes with the shifter and put the joystick.h file in the libraries folder. when i come to verify/compile the code it comes back with


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

C:\DIYSimShifter\DIYSimShifter.ino: In function 'void setup()':

DIYSimShifter:24:11: error: expected unqualified-id before '.' token

Joystick.begin();

^

C:\DIYSimShifter\DIYSimShifter.ino: In function 'void loop()':

DIYSimShifter:34:11: error: expected unqualified-id before '.' token

Joystick.setButton(0,!Up);

^

DIYSimShifter:35:11: error: expected unqualified-id before '.' token

Joystick.setButton(1,!Down);

^

exit status 1

expected unqualified-id before '.' token



This report would have more information with
"Show verbose output during compilation"

option enabled in File -> Preferences.



The code included is :

//////////////////////////////////////////////////
// DIY Sim Shifter - For Arduino Leo/ProMicro //
// //
// By Brendan Beavis //
// v1.0 //
//////////////////////////////////////////////////

#include <Joystick.h>

//declare our digital input pins on the board
int upPin = 8;
int downPin = 5;

//this is the value of the input from the switches
int Up = 0;
int Down = 0;

void setup() {
//setup our pins
pinMode(upPin, INPUT_PULLUP);
pinMode(downPin, INPUT_PULLUP);

//setup the joystick library
Joystick.begin();
}

void loop( ){

//read our values from the switches to the digital input pins
Up = digitalRead(upPin);
Down = digitalRead(downPin);

//write the value of the input to the joystick buttons.
Joystick.setButton(0,!Up);
Joystick.setButton(1,!Down);

//wait a moment before rechecking the status of the inputs
delay(50);
}



Can anyone help with this please as ive no idea what im doing wrong.

Thanks
 
Considering the electrical bits consist of two switches you could probably use the sim hub arduino sketch utility to write a configuration that achieves the same thing. In essence you should be able to tell the sketch tool your 2 data pins and have them act as buttons. I have created my own button box matrix using this utility and it works great so I imagine this use case should as well if your unable to use the supplied code.
 
Upvote 0
Looks like there is a problem with the Joystick Library. Does it appear in the Sketch => Include Library menu?
Refer to this guide how to install libraries in the Arduino IDE. You can either use the Importing a .zip Library or the Manual installation method.
If that doesn't work, you can get the latest version of this library here.
 
Upvote 0
Looks like there is a problem with the Joystick Library. Does it appear in the Sketch => Include Library menu?
Refer to this guide how to install libraries in the Arduino IDE. You can either use the Importing a .zip Library or the Manual installation method.
If that doesn't work, you can get the latest version of this library here.
Thankyou, I didn't have the joystick library installed correctly. It now works perfect.
 
Upvote 0

Latest News

Online or Offline racing?

  • 100% online racing

    Votes: 105 8.0%
  • 75% online 25% offline

    Votes: 134 10.2%
  • 50% online 50% offline

    Votes: 189 14.4%
  • 25% online 75% offline

    Votes: 369 28.1%
  • 100% offline racing

    Votes: 513 39.0%
  • Something else, explain in comment

    Votes: 5 0.4%
Back
Top