Push button, Arduino, Dc motor

You should also repost a pic of your current wiring.
When you make a change to either your code or your wiring, you should post those so that everyone is current on what exact changes were made.

A photo of your actual circuit would be better than a Fritzy diagram.

In this picture it is not recognisable which wires are connected from switch to ground and from switch to IO-pin 3

You have to check the picture if it is easy to see on the picture before posting it.

Do you have a wire from GND on the Arduino to GND on the board in the top of the pic?

The black wire is connecting with ground and red wire is connecting with IO-pin3.

Ok, from the pic it looks like the black wire is going straight to the board on the top of the photo.

Post a hand drawn schematic of your project.

In the meantime, I'm off to feed the penguins.

Everything? Or just the switch.

  1. It's IO-pin 3
  2. It doesn't have a solid end
  3. No, it's the next one at the left.

I don't understand this.
please post a better picture where it is easy to see which wire is connected to which socket.
You will have to take the picture from almost vertical above so that the letters on the board are visible

If the red wire does not have a solid end it is very likely that the contact to the breadboard is loose

can you really see

just from the picture

which exact socket the wire is plugged in?
I can not!

de-isolate about half an inch of the black and the red wire

cut off one pin from one of the jumper-wires
de-isolate about half an inch the end of the jumper-wire
twist together the jumper-wire and the wire coming from the button.

Do this for both wires coming from the button.
This means you do not need the breadboard for the button-wiring

very important !

to avoid shortcuts isolate the twisted blank wires with some adhesive tape
make sure that the wires on the button have tight contact.

Seems like it didn't work. i twisted it together but still isn't working.

do you have a LED and a resistor in the range of 300 Ohm to 1000 Ohm?
This could be used as a simple test if a wiring is conductant or not.
The part of the wiring you want to test must be DIS-connected from the arduino.

Connections to the arduino can be tested by digitalRead()

Did you ever take a look at this WOWKI-simulation?

It does print the IO-state of IO-pin 3 once per second so you can check what the IO-pins state is

It's either my wiring or my button is just bad. Or maybe I use wrong button? Or it's not high quality enough.

You can find out what is wrong
if you upload this code from the WOKWI-simulation

int In1 = 7;
int In2 = 8;
int ENA = 5;
int SPEED = 255;
int In3 = 4;
int In4 = 6;
int ENB = 2;
int In5 = 10;
int In6 = 9;
int ENA2 = 11;
const int buttonPin = 3;
int stop = 0;

unsigned long myDebugPrintTimer = 0;                   // Timer-variables MUST be of type unsigned long
const byte    OnBoard_LED = 13;


void setup() {
  // if you want to use serial printning
  // you have to do a call to function Serial.begin(baudrate);
  Serial.begin(115200);
  Serial.println("Setup-Start");
  pinMode(In1, OUTPUT);
  pinMode(In2, OUTPUT);
  pinMode(ENA, OUTPUT);
  pinMode(In3, OUTPUT);
  pinMode(In4, OUTPUT);
  pinMode(ENB, OUTPUT);
  pinMode(In5, OUTPUT);
  pinMode(In6, OUTPUT);
  pinMode(ENA2, OUTPUT);
  pinMode(buttonPin, INPUT_PULLUP);
}


void loop()  {
  oncePerSecondPrintDebugInfo();

  if (digitalRead(buttonPin) == LOW ) {
    // Button was pressed
    // Start the code sequence

    Serial.println("Button pressed. Running code...");
    digitalWrite(In1, HIGH);
    digitalWrite(In2, LOW);
    Serial.println("A Motor1 Right");
    delay(1000);

    digitalWrite(In1, LOW);
    digitalWrite(In2, LOW);
    Serial.println("B Motor1 Stop");
    delay(2000);

    digitalWrite(In1, LOW);
    digitalWrite(In2, HIGH);
    Serial.println("C Motor1 Left");
    delay(1000);

    digitalWrite(In1, LOW);
    digitalWrite(In2, LOW);
    Serial.println("D Motor1 Stop");
    delay(2000);
    analogWrite(ENA, SPEED);

    digitalWrite(In3, HIGH);
    digitalWrite(In4, LOW);
    Serial.println("E Motor2 Right");
    delay(1000);

    digitalWrite(In3, LOW);
    digitalWrite(In4, LOW);
    
    digitalWrite(In3, LOW);
    digitalWrite(In4, HIGH);
    Serial.println("F Motor2 Left");
    delay(1000);

    digitalWrite(In3, LOW);
    digitalWrite(In4, LOW);
    Serial.println("G Motor2 Stop");
    delay(2000);

    analogWrite(ENB, SPEED);

    digitalWrite(In5, HIGH);
    digitalWrite(In6, LOW);
    Serial.println("H Motor3 Right");
    delay(1000);

    digitalWrite(In5, LOW);
    digitalWrite(In6, LOW);
    Serial.println("I Motor3 Stop");
    delay(2000);

    digitalWrite(In5, LOW);
    digitalWrite(In6, HIGH);
    Serial.println("J Motor3 Left");
    delay(1000);

    digitalWrite(In5, LOW);
    digitalWrite(In6, LOW);
    Serial.println("K Motor3 Stop");
    delay(2000);

    analogWrite(ENA2, SPEED);

    Serial.println("Code sequence ended.");
    digitalWrite(In1, LOW);
    digitalWrite(In2, LOW);
    digitalWrite(ENA, stop);
    
    digitalWrite(In4, LOW);
    digitalWrite(In5, LOW);
    digitalWrite(ENB, stop);
    
    digitalWrite(In5, LOW);
    digitalWrite(In6, LOW);

    analogWrite(ENA2, stop);
  }
}


// easy to use helper-function for non-blocking timing
boolean TimePeriodIsOver (unsigned long &startOfPeriod, unsigned long TimePeriod) {
  unsigned long currentMillis  = millis();
  if ( currentMillis - startOfPeriod >= TimePeriod ) {
    // more time than TimePeriod has elapsed since last time if-condition was true
    startOfPeriod = currentMillis; // a new period starts right here so set new starttime
    return true;
  }
  else return false;            // actual TimePeriod is NOT yet over
}


void BlinkHeartBeatLED(int IO_Pin, int BlinkPeriod) {
  static unsigned long MyBlinkTimer;
  pinMode(IO_Pin, OUTPUT);
 
  if ( TimePeriodIsOver(MyBlinkTimer, BlinkPeriod) ) {
    digitalWrite(IO_Pin, !digitalRead(IO_Pin) );
  }
}


void oncePerSecondPrintDebugInfo() {

  if ( TimePeriodIsOver(myDebugPrintTimer,1000) ) {
    Serial.print("IO-Pin No ");
    Serial.print(buttonPin);
    Serial.print(" has state ");
    if (digitalRead(buttonPin) == LOW) {
      Serial.print("LOW");      
    }
    else {
      Serial.print("HIGH");      
    }
    Serial.println();
  }
}

Here is a short code t hat does nothing else than print to the serial monitor what the state of IO-pin 3 is

The values should change between "1" if buntton is released
and
value "0" if button is pressed and all wiring is corrcect and conductant

The blinking of the onboard-LED shows that the code is running

const int buttonPin = 3;

unsigned long MyTestTimer = 0;                   // Timer-variables MUST be of type unsigned long
const byte    OnBoard_LED = 13;


void setup() {
  Serial.begin(115200);
  Serial.println("Setup-Start");
  pinMode(buttonPin, INPUT_PULLUP);
}


void loop() {
  BlinkHeartBeatLED(OnBoard_LED,250);

  if ( TimePeriodIsOver(MyTestTimer,1000) ) {
    Serial.print("state of IO-pin No ");
    Serial.print(buttonPin);
    Serial.print("=");
    Serial.println(digitalRead(buttonPin) );    
  }  
}


// easy to use helper-function for non-blocking timing
boolean TimePeriodIsOver (unsigned long &startOfPeriod, unsigned long TimePeriod) {
  unsigned long currentMillis  = millis();
  if ( currentMillis - startOfPeriod >= TimePeriod ) {
    // more time than TimePeriod has elapsed since last time if-condition was true
    startOfPeriod = currentMillis; // a new period starts right here so set new starttime
    return true;
  }
  else return false;            // actual TimePeriod is NOT yet over
}


void BlinkHeartBeatLED(int IO_Pin, int BlinkPeriod) {
  static unsigned long MyBlinkTimer;
  pinMode(IO_Pin, OUTPUT);
  
  if ( TimePeriodIsOver(MyBlinkTimer,BlinkPeriod) ) {
    digitalWrite(IO_Pin,!digitalRead(IO_Pin) ); 
  }
}

best regards Stefan

I'm thinking about just buy new button that has pin legs so it directly connect with the bread board.