Motor not responding on button click

this is my code and my motor does not respond on button click. the circuit is alright and i am not able to diagnose it help.

 #include <AFMotor.h>

AF_DCMotor Rmotor(4, MOTOR12_1KHZ); // create motor #2, 64KHz pwm
AF_DCMotor Lmotor(3, MOTOR12_1KHZ); 
void setup() {
  pinMode(13, OUTPUT);    // Use Built-In LED for Indication
  pinMode(8, INPUT_PULLUP);
              // set up Serial library at 9600 bps
  Serial.println("Motor test!");
void loop() {
  bool buttonState = digitalRead(8);


Welcome to the forum.

How have you got your button wired?

Can you please post a picture of your project?
Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?
What does your monitor show?

Tom... :slight_smile:

What do your debug prints tell you?

For testing, try putting delay(500); into loop(). I suspect you are sending too much stuff to the Serial Monitor and the Arduino is choking on it. Be aware that loop() repeats 1000 times per second or more.