Hey guys, don't be rude but my Question is quite simple/dumb
I have some NC Pushbuttons, and connected each with a pin and the common. (Teensy 2.0)
Whats the code for this? Nothing seems to work. I have had a code example already on my PC from several days back.
Should work like this:
NCs connecting Pin to the ground (Button not pressed)
--> Press button
Pullup Resistor pulls the pin to high signal
--> "Active High"
In fact, the problem ist my (non existing) general knowledge about arduino codes.
Sorry for your wasted time
Regards
I have some NC Pushbuttons, and connected each with a pin and the common. (Teensy 2.0)
Whats the code for this? Nothing seems to work. I have had a code example already on my PC from several days back.
Code:
pinMode(PIN_D3, INPUT_PULLUP); // PIN_B3
pinMode(4, INPUT_PULLUP); // PIN_B7
pinMode(5, INPUT_PULLUP); // PIN_D0
pinMode(6, INPUT_PULLUP); // PIN_D1
pinMode(7, INPUT_PULLUP); //PIN_D2
pinMode(8, INPUT_PULLUP); //PIN_D3
pinMode(9, INPUT_PULLUP);
pinMode(10, INPUT_PULLUP);
pinMode(22, INPUT_PULLUP);
pinMode(23, INPUT_PULLUP);
}
void loop() {
// Update all the buttons. There should not be any long
// delays in loop(), so this runs repetitively at a rate
// faster than the buttons could be pressed and released.
button3.update();
button4.update();
button5.update();
button6.update();
button7.update();
button8.update();
button9.update();
button10.update();
if (button3.fallingEdge()) {
Joystick.button(4, 0);
}
if (button4.fallingEdge()) {
Joystick.button(5, 0);
}
if (button5.fallingEdge()) {
Joystick.button(6, 0);
}
if (button6.fallingEdge()) {
Joystick.button(7, 0);
}
if (button7.fallingEdge()) {
Joystick.button(8, 0);
}
if (button8.fallingEdge()) {
Joystick.button(9, 0);
}
if (button9.fallingEdge()) {
Joystick.button(10, 0);
}
if (button22.fallingEdge()) {
Joystick.button(23, 0);
}
if (button23.fallingEdge()) {
Joystick.button24, 0);
}
if (button3.risingEdge()) {
Joystick.button(4, 1);
}
if (button4.risingEdge()) {
Joystick.button(5, 1);
}
if (button5.risingEdge()) {
Joystick.button(6, 1);
}
if (button6.risingEdge()) {
Joystick.button(7, 1);
}
if (button7.risingEdge()) {
Joystick.button(8, 1);
}
if (button8.risingEdge()) {
Joystick.button(9, 1);
}
if (button9.risingEdge()) {
Joystick.button(10, 1);
}
if (button10.risingEdge()) {
Joystick.button(11, 1);
}
if (button22.risingEdge()) {
Joystick.button(23, 1);
}
if (button23.risingEdge()) {
Joystick.button(24, 1);
}
}
Should work like this:
NCs connecting Pin to the ground (Button not pressed)
--> Press button
Pullup Resistor pulls the pin to high signal
--> "Active High"
In fact, the problem ist my (non existing) general knowledge about arduino codes.
Sorry for your wasted time
Regards