Hey guys,
Total arduino noob here, have been trying to do as much research as possible before posting here but I am really not understanding much of what im reading or not finding what im looking for (i think)
I am in the process of designing and building a new sequential shifter for my simulator rig with a couple of added switches. Basing my design on the Jinx shifter system ( V2 JINX Shifter and Brake Bias Gaming Combo - Black – Jinx Shifters Pty Ltd ) that has the shifter and then brake balance control as well.
I am yet to purchase the arduino board but everything I read from guys who have done their own shifters I am leaning towards the ProMicro.
I have downloaded the code from the shifter Beavis Motorsport has on his website ( BEAVIS Motorsport ) but am wondering what the best way of adding the control for the brake balance would be?
//////////////////////////////////////////////////
// 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);
}
The code here is just for the shifter and the function of the brake balance controller would be exactly the same as the shifter but just on its own switches. So can anyone point me in the right direction of what I would need to add to this code? Can I just duplicate the code as above and change to say 'Left and Right' instead of up and down? and then assign those to 2 pins on the board?
Once again im new to arduino and coding so im probably way off here. Thanks
//////////////////////////////////////////////////
// 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;
int leftPin = 9;
int rightPin = 6;
//this is the value of the input from the switches
int Up = 0;
int Down = 0;
int Left = 0;
int Right = 0;
void setup() {
//setup our pins
pinMode(upPin, INPUT_PULLUP);
pinMode(downPin, INPUT_PULLUP);
pinMode(leftPin, INPUT_PULLUP);
pinMode(rightPin, 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);
Left = digitalRead(leftPin);
Right = digitalRead(rightPin);
//write the value of the input to the joystick buttons.
Joystick.setButton(0, !Up);
Joystick.setButton(1, !Down);
Joystick.setButton(2, !Left);
Joystick.setButton(3, !Right);
//wait a moment before rechecking the status of the inputs
delay(50);
}
I went ahead and added in what I think is right, going to try and pickup a board this week and hopefully put it into practice. Can anyone tell me if there is anything way off here?
Many Thanks.
Assuming the first code works, your version looks plausible. Only testing will really tell you though. You may want to validate that what you started with actually works with your hardware first.
Yeh cool thanks.
I tried verifying the first one in the IDE software but got an error but I assume that's because I didn't have hardware connected yet... would that be correct?
I bought a micro online from a local store and will get to pick it up in the morning so will be able to do a proper test then.
beardedviking88:
I tried verifying the first one in the IDE software but got an error but I assume that's because I didn't have hardware connected yet... would that be correct?
No. Verify is just compiling the program - whether you have the hardware doesn't matter.
I'll guess that you don't have the joystick library installed - that's what the error indicates if I try to compile it.
It sounds like you have added Joystick.cpp and Joystick.h to your program, but you also have them pulled in from the library so everything is showing up as duplicates.
I suggest that you close the IDE and find the directory with your code in it and delete the two Joystick files from that directory. Then reopen the IDE and try again.
You may instead want to create a new sketch entirely and just copy the code you pasted earlier into it.
BOOM - that did it.
Thanks so much mate, you are a legend!! - hopefully i will be able to get my board today and do some proper testing.