I got a Arduino Mega 2560 (the new one) and I use it with JunXion.
I will use it with JunXion to convert the serial signals from the Arduino i MIDI.
The problem is, when I connect a regular push button to GND and PIN22 (which is configured in the sketch)
the value in JunXion flickers. 0.00, 127, 0.00, 127... and so on. But when I push the button, the value
stays on 0.00 until I release again. Then it starts flickering again.
I've also tested to connect a 1k resistor between button and GND, but that didn't work! The same thing happens!
I'm a complete Arduino newbie. But I have some knowledge in electronics...
I would be so glad if you can point me in the correct direction!
What you have is called a 'floating input' pin when you are not pressing the button, it just reads noise as there is no valid logic high voltage being applied to the pin when the switch is released.
If you wire your 1k resistor from the input pin to +5vdc, I think you will see it will work. One can also instead enable an internal software enabled pull-up resistor for the input pin by doing a digitalWrite(pin#,HIGH); right after the mode command setting the pin to input mode.
It isn't flickering anymore... I've connected the resistor to 5V and to PIN22.. and a push button between PIN22 and GND...
When the button isn't pushed, the value is 127. When I push it, it sais 0.00.
But why on earth does the Arduino need this extra resistor?
What happens when I will connect a LED to this circuit?
Like, if I want a LED that lights up when the button is pushed, AND the serial is sent.
See attached schematic. That's how I want it... Will that work with the extra resistor (they are not in the schematic by now). This schematic is for an old circuit that I made with a regular gamepad pcb. But now I want to make this with the Arduino instead!
You will need pull down resistors on that circuit on the sensing lines so that normally the input is connected to ground (through the resistor) and pushing the button connects it to +5.
The button send the serial signal correctly... But the problem is that the LED is on when the button is release, and dimmed when the button is pushed... I guess that it is this way because PIN22 is connected to 5V through the pull down resistor.
I am a bit confused now, that is a lot of code to do so little. I can't find any pin definition. What value is your pull down resistors?
Is it wired up just like the last post? You must have something wrong. Any chance of a photo?