Push button question

Can I use a push button module like this and connect it to the analog ports on the Arduino uno or must I use a breadboard with push button?

Surely the breadboard isn't an absolute must. You could solder some wires to it and run them directly over to the Arduino board.

What are you trying to do? You can hook it up anyway you choose but $4.33 seems a bit much for a push button switch. Why not just get the switch and hook it up direct? Can you solder wires? That's all you need. Actually you can get a few wires with alligator clips and hook it up too. Again, it all depends on what you are trying to do but you can hook the button up anyway you can manage. No breadboard needed.

Right now I have digital pins + ground on the uno connected to a stepper motor. The uno is programmed to turn and stop every 10 seconds. The program works fine.

My goal here is to have a push button (preferably bigger than a pencil eraser) connected to the analog pins (since I'll need an additional ground and can use analog as digital). When the button is pressed, the working program will initiate.

I'm new to arduino and have been pretty comfortable using the jumper wires to get this working so far. Soldering wires is not a problem if I know the right button to get and where to solder to.

Thanks

Cmjb13: Soldering wires is not a problem if I know the right button to get and where to solder to.

See the little pins coming out of the board the button is on? Solder to those.

But where am I soldering these to on the uno?

The module has 3 pins S=output +=DC 5V -=GND

Couldn't I just use a male to female jumper wire instead?

Cmjb13: But where am I soldering these to on the uno?

The module has 3 pins S=output +=DC 5V -=GND

Couldn't I just use a male to female jumper wire instead?

Yeah, you could use a jumper. It doesn't matter. An electrical connection is an electrical connection. You could proabably take a paper clip and wrap it tightly around those pins and jam it into the header on the arduino and make it work. I wouldn't advise that, but my point is that it doesn't matter HOW you connect them just that you get them connected somehow.

I gather the +(DC 5V) and -(GND) pins go to the power pins on the UNO.

Where would the S (output) pin go to the uno? (I have Uno R3)

Cmjb13: I gather the +(DC 5V) and -(GND) pins go to the power pins on the UNO.

Where would the S (output) pin go to the uno? (I have Uno R3)

Well, let's think about it. You need to read the button and you can't do that through the 5V pin or the ground pin.

Yes.

Connect 5v to 5v, gnd to gnd, and the output to your analog input. The module will have it’s own pull-up or pull-down resistor. Write a sketch to just print the value of the pin so as to see what you get when the switch is pressed/not pressed.

Was just thinking about this…

Once the button is installed, I want to press the button once and have the program cycle through.

I don’t want to have to hold the button in order for the program cycle to complete.

Can this be changed via code?

/*
Stepper Motor Control - one revolution

This program drives a unipolar or bipolar stepper motor.
The motor is attached to digital pins 8 - 11 of the Arduino.

The motor should revolve one revolution in one direction, then
one revolution in the other direction.

Created 11 Mar. 2007
Modified 30 Nov. 2009
by Tom Igoe

*/

#include <Stepper.h>
int x = 0;
const int stepsPerRevolution = 200; // change this to fit the number of steps per revolution
// for your motor

// initialize the stepper library on pins 8 through 11:
Stepper myStepper(stepsPerRevolution, 8, 9, 10, 11);

void setup() {
// set the speed at 60 rpm:
myStepper.setSpeed(63);
// initialize the serial port:
Serial.begin(9600);
}

void loop() {
if (x <= 10)
{ // step one revolution in one direction:
Serial.println(“clockwise”);
myStepper.step(stepsPerRevolution);
// delay(500);
x++;
}

// step one revolution in the other direction:
// Serial.println(“counterclockwise”);
// myStepper.step(-stepsPerRevolution);
// delay(500);
}

Cmjb13: Once the button is installed, I want to press the button once and have the program cycle through. I don't want to have to hold the button in order for the program cycle to complete. Can this be changed via code?

Ok, so your program has two states: doing stuff and not doing stuff.

boolean doing_stuff =false;

If your code is not doing stuff, then you want it to begin dong stuff if the button goes high. If it is doing stuff, then you want it to continue doing stuff until it is finished.

void loop() {
  if(doing_stuff) {
    do my loop thing;
    if(my loop thing is finished) {
      doing_stuff = false;
    }
  }
  else {
    if(button is down) {
      doing_stuff = true;
    }
  }
}