I am new to electronics compared to many here I’m sure, but I have some experience with Arduinos and basic circuits and PCBs. If for example I had two mechanical keyboard switches wired up to an Arduino board’s digital pins (one ground wire and two for the signals), and they are designed to trigger only once upon each keypress, what do I need to do so that I can switch on command for the Arduino to read each input twice (or more) in rapid succession instead of only once? I don’t need such a feature all the time, so I’d like it to be something I can control via some switch if possible. Thank you.
What if they were not wired that way and in a way you want…?
I’m not sure I get the question. Is this an hypothetical example or do you have those keyboards? Any link or more info on what the buttons look like would probably get you more answers.
Save yourself a lot of work, save the state of the switch in a variable. You can use bool, byte, int etc they will all work. bool or if you are not familiar with it use int.
I am modifying a game controller that will be using 7 mechanical keyboard switches, 5 of which can remain as they are. I would like for two of said switches to be able to toggle between two different modes, from being triggered once per press to being triggered twice per press, essentially doubling the output for the same amount of effort. I assume the Arduino is what does that. This is a hypothetical setup, but one I know works because I used it before, so I will use it. The seven switches are connected to the digital pins 2-6 and 8 and 9 and of course ground pins. Can the Arduino be toggled so the pins see the signals from 8 and 9 and repeat it rapidly, but only once per key press?
Are you saying you can see the key press as a pulse on the digital pin ?
You can sure do what you want in code if you can capture a button pressed signal.
I think that is what I am wanting. I mean coding is something I admittedly didn’t exactly study. I just assumed I could describe what was needed and get an example code that I could reverse engineer if needed. Also I think the pins are high be default, but I’m not 100% on that. Essentially if the switches actuate once, they get read twice rapidly each time in game, but I would like that feature to be toggle-able on the fly and not permanent. Any code I used for the Arduino was code that was premade. The only coding I ever did was editing a couple numbers lol.
If I understand you correctly, you have a couple of buttons that are being read/polled by some undiscussed piece of equipment (a game computer or something like that) and you want to add an Arduino to it that listens for button presses and essentially duplicates each button press. With the addition that this duplication function must be enabled or disabled by the user so that the buttons can also be used in their original configuration. Yes?
I think it's possible. You'd essentially be using the Arduino ports with the buttons attached to it first as an input (listen for a button press) and then briefly as an output ('fake' an additional button press).
How it works out in hardware etc. depends on the controller and attached circuitry.
Post pictures or link to the game controller
How do you know about the wiring and single pulse?
First of all thank you for the responses everyone and the willingness to help. I will post pics when I get back home. I am at the vet right now. As for how I know what I know, I have modded three other controllers like this before, but never with the kind of toggle I describe. I’ll get back to you.
Yes it is a game controller with an Arduino pro micro inside serving as the brain so to speak which is plugged via USB into the computer. I can post pictures when I get back home.
Oh then it's even simpler. For any button press simply send to triggers over the USB instead of one. Existing code should be quite easy to modify to accomplish this.
Can that feature be wired to a switch and work on the hardware level too so that I could turn it on whenever, or is that something that once it is turned on it’s just on until coded back?
Sure.
Hm. I guess I’ll have to do some reading. I understand the general concept but have no idea how to execute with the near non existent coding experience and limited experience with circuitry. So I’ll look around.
The idea is pretty simple. You take your switch (let's assume a simple toggle switch, one of those little levers) that controls if the feature is effective, read it from the Arduino and if it's on, you send the command that associates with a particular button press twice. If it's off, you only send the button command once.
Let's see the code of that controller, maybe someone can give you a pointer of where to insert the two/three lines of code that will make this happen.
Is there a way to view the code to the board if I didn’t use Arduino IDE to upload any code to is? I used a third party application called guitar configurator by sanjay900 specifically used for this sort of thing to streamline the process. I may have to just start the coding over and use the IDE program that way I can actually edit the code instead of having a program do it all for me.
please edit your post, select the code part and press the </> icon in the tool bar to mark it as code. It’s barely readable as it stands. (also make sure you indented the code in the IDE before copying, that’s done by pressing ctrlT on a PC or cmdT on a Mac)
#include <Joystick.h>
Joystick_ Joystick;
int RxAxis_ = 0;
int LxAxis_ = 0;
int LyAxis_ = 0;
const bool initAutoSendState = true;
void setup()
{
pinMode (4, INPUT_PULLUP);
pinMode (5, INPUT_PULLUP);
pinMode (6, INPUT_PULLUP);
pinMode (7, INPUT_PULLUP);
pinMode (14, INPUT_PULLUP);
pinMode (8, INPUT_PULLUP);
pinMode (9, INPUT_PULLUP);
pinMode (10, INPUT_PULLUP);
pinMode (16, INPUT_PULLUP);
pinMode (15, INPUT_PULLUP); //right
Joystick.begin();
}
void loop() {
{
if (digitalRead(4) == LOW)
Joystick.pressButton(0);
else
Joystick.releaseButton(0);
}
{
if (digitalRead(5) == LOW)
Joystick.pressButton(1);
else
Joystick.releaseButton(1);
}
{
if (digitalRead(6) == LOW)
Joystick.pressButton(2);
else
Joystick.releaseButton(2);
}
{
if (digitalRead(7) == LOW)
Joystick.pressButton(3);
else
Joystick.releaseButton(3);
}
{
if (digitalRead(8) == LOW)
Joystick.pressButton(4);
else
Joystick.releaseButton(4);
}
{
if (digitalRead(14) == LOW)
Joystick.pressButton(5);
else
Joystick.releaseButton(5);
}
{
if (digitalRead(9) == LOW)
Joystick.pressButton(6);
else
Joystick.releaseButton(6);
}
{
if (digitalRead(10) == LOW)
Joystick.pressButton(7);
else
Joystick.releaseButton(7);
}
{
if (digitalRead(16) == LOW)
Joystick.pressButton(8);
else
Joystick.releaseButton(8);
}
{
RxAxis_ = analogRead(A0);
RxAxis_ = map(RxAxis_, 1023, 0, 1023, 0);
Joystick.setRxAxis(RxAxis_);
}
delayMicroseconds(1000);
}
This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.
