Last time, I swear...

OK, this is the last time I’m asking for help, I swear:

The purpose of my project is this: there are 4 buttons, an LED, a motor, and a switch (different from a button because it serves a different purpose). Three buttons are “rotation” buttons. If I press button 1, it adds 100 to a counter, 2 adds 10 to a counter, and 3 adds 1 to a counter. The fourth button is the “go” button. When I press the go button, the motor should turn until the switch, which is pressed by the axle of the motor every rotation, is pressed the same number of times in the counter. The LED lights up every time you press a button, just so your sure you pushed it in all the way. Sounds simple, right? I hooked up all the wires and tested it. I left out the switch, so when I press the go button it should just go indefinitely. It didn’t work; the LED stayed on the whole time and the motor randomly turned on and off, without my ever pressing a button. And pressing the buttons didn’t do anything. I tried re-writing the program several times and rewiring it, but nothing seems to work. Can anyone else see the problem here?

Here is the circuit:

It’s kinda messy so I will explain it:
Two yellow wires come from the 5V and the Ground to the breadboard. All four buttons have the same circuit: 5V to 680 Ohm resistor to Button and back to the appropriate pin on the Arduino. For the motor, the green wire to the far left goes from the 5V to the collector of a transistor. The base is attached to pin 12, and the emitter goes to the top of the breadboard via a small yellow wire. Then it goes to the motor, which comes back to the breadboard, which goes to the Ground. The LED is sticking out of pin 13 and into ground. There is a red wire that appears to come from the Arduino and go back into it; that’s just there to hold the Arduino onto the breadboard, it does nothing.

Here is my program:

int motorPin = 12;
int ledPin = 13;
int hundredPin = 1;
int tenPin = 2;
int onePin = 3;
int goPin = 4;
int rotationPin = 5;

int counter = 0;

void setup()
{
  pinMode(motorPin, OUTPUT);
  pinMode(ledPin, OUTPUT);
  
  pinMode(hundredPin, INPUT);
  pinMode(tenPin, INPUT);
  pinMode(onePin, INPUT);
  pinMode(goPin, INPUT);
  
  pinMode(rotationPin, INPUT);
  Serial.begin(9600);
}

void loop()
{
  Serial.println( digitalRead(goPin) );
  if(digitalRead(hundredPin) == HIGH)
  {
    counter = counter + 100;
    digitalWrite(ledPin, HIGH);
    delay(200);
    digitalWrite(ledPin, LOW);
  }
  if(digitalRead(tenPin) == HIGH)
  { 
    counter = counter + 10; 
    digitalWrite(ledPin, HIGH);
    delay(200);
    digitalWrite(ledPin, LOW);
  }
  if(digitalRead(onePin) == HIGH)
  {
    counter = counter + 1;
    digitalWrite(ledPin, HIGH);
    delay(200);
    digitalWrite(ledPin, LOW);
  }
  if(digitalRead(goPin) == HIGH)
  {
    int x = 0;
    digitalWrite(ledPin, HIGH);
    digitalWrite(motorPin, HIGH);
    while(x < counter)
    {
      if(digitalRead(rotationPin) == HIGH)
      {
        x++;
      }
    }
    digitalWrite(motorPin, LOW);
    digitalWrite(ledPin, LOW);
  }
}

The Serial.println(digitalRead(goPin)); command returns a 1 for when the motor is not moving and a 0 for when the motor is moving (it might have been the other way around, I’m not sure).

I appreciate any help you guys give me, you have been great so far!

I don’t see where you tied the buttons to ground, so your inputs are most likely floating. Have a look at the button tutorial here.

I don’t see where you tied the buttons to ground, so your inputs are most likely floating. Have a look at the button tutorial here.

That was a problem, thank you. Another problem I noticed is that I connected one to pin “1”, which has the letters “TX” under it. I’m not sure what it means, but the combination of attaching the buttons to ground and moving all the wires up one pin worked. Thank you!

Pin 0 nd 1 are the Transmit (TX) and recieve (RX) pins for the serial communications, duplicating the USB interface.

Having things hooked up to them while using serial communication over the “USB” port is not a good idea.