user19667: I am trying to build a simple motor test sketch, currently, to test a NEMA 23 stepper motor and the DM542T stepper driver.
Here is the code, and I am having trouble figuring out how to properly wire the 5-lead button (+, -, Common, NO, NC)
Here is the code
// Pin numbers
const int buttonPin = 2;
const int directionPin = 8;
const int stepPin = 9;

// Other constants
const int NumSteps = 5000; // steps
const int Speed = 500; 

void setup() {
  pinMode(buttonPin, INPUT_PULLUP);
  pinMode(directionPin, OUTPUT);
  pinMode(stepPin, OUTPUT);
  digitalWrite(directionPin, LOW);
  digitalWrite(stepPin, LOW);
}

void loop() {
  if (digitalRead(buttonPin)) {
    // Move in one direction
    for (int distance = 0; distance < NumSteps; distance++) {
      digitalWrite(stepPin, HIGH);
      delayMicroseconds(Speed);
      digitalWrite(stepPin, LOW);
      delayMicroseconds(Speed);
    }
   // Reverse direction
   digitalWrite(directionPin, !digitalRead(directionPin));
 }
  delay(5);
}

The button is a momentary button, so I am holding it in to simulate a latching button.
I have the buttons Common and Neg leads wired together, and connected to the Gnd pin on the Arduino (mega rev3)
I have the buttons Positive and the NC wired together and connected to pin 2.
Wiring that button in that manner, works fine in the button-controlled blink sketch, but is not working here (LED on the button doesn't light up and the motor test doesn't run).
Note: I am using a 5 lead momentary button as that what the project these motors will be for will be using.
Any help appreciated.

user4143: The button's pins are as follows:

+: The LED's anode
-: The LED's cathode
C: The common pin of the switch
NC: Normally Closed - is normally connected to the C pin until the button is pressed
NO: Normally Open - is connected to the C pin when you press the button

So to use the button as a button the two pins you care about are C and NO. Use those pins (in any order) as you would any normal button with a pullup resistor (or the internal INPUT_PULLUP resistor).
To use the LED can be a little more tricky. Most of this style of button have the LED set up for 12V usage. While you may get a slight glow from it from 5V you would probably need to switch it with a transistor and power it from 12V to get it to light up properly. However your button may be rated differently and need a different voltage.

19667: <p>I am trying to build a simple motor test sketch, currently, to test a NEMA 23 stepper motor and the DM542T stepper driver.</p>
<p>Here is the code, and I am having trouble figuring out how to properly wire the 5-lead button (+, -, Common, NO, NC)</p>
<p>Here is the code</p>
<pre><code>// Pin numbers
const int buttonPin = 2;
const int directionPin = 8;
const int stepPin = 9;

// Other constants
const int NumSteps = 5000; // steps
const int Speed = 500; 

void setup() {
  pinMode(buttonPin, INPUT_PULLUP);
  pinMode(directionPin, OUTPUT);
  pinMode(stepPin, OUTPUT);
  digitalWrite(directionPin, LOW);
  digitalWrite(stepPin, LOW);
}

void loop() {
  if (digitalRead(buttonPin)) {
    // Move in one direction
    for (int distance = 0; distance &lt; NumSteps; distance++) {
      digitalWrite(stepPin, HIGH);
      delayMicroseconds(Speed);
      digitalWrite(stepPin, LOW);
      delayMicroseconds(Speed);
    }
   // Reverse direction
   digitalWrite(directionPin, !digitalRead(directionPin));
 }
  delay(5);
}
</code></pre>
<p>The button is a momentary button, so I am holding it in to simulate a latching button.</p>
<p>I have the buttons Common and Neg leads wired together, and connected to the Gnd pin on the Arduino (mega rev3)
I have the buttons Positive and the NC wired together and connected to pin 2.</p>
<p>Wiring that button in that manner, works fine in the button-controlled blink sketch, but is not working here (LED on the button doesn't light up and the motor test doesn't run).</p>
<p>Note: I am using a 5 lead momentary button as that what the project these motors will be for will be using.</p>
<p>Any help appreciated.</p>
 4143: <p>The button's pins are as follows:</p>
<ul>
<li>+: The LED's anode</li>
<li>-: The LED's cathode</li>
<li>C: The common pin of the switch</li>
<li>NC: Normally Closed - is normally connected to the C pin until the button is pressed</li>
<li>NO: Normally Open - is connected to the C pin when you press the button</li>
</ul>
<p>So to use the button as a button the two pins you care about are C and NO. Use those pins (in any order) as you would any normal button with a pullup resistor (or the internal <code>INPUT_PULLUP</code> resistor).</p>
<p>To use the LED can be a little more tricky. Most of this style of button have the LED set up for 12V usage. While you <em>may</em> get a slight glow from it from 5V you would probably need to switch it with a transistor and power it from 12V to get it to light up properly. However your button may be rated differently and need a different voltage.</p>
