Plug sensor on robot

Hello,

We were wondering how to plug sensor on the robot. We try to plug a push buton on M2 port, we would like that when this button is in high state the robot move.

#include <ArduinoRobot.h>
#include <Wire.h>[table]
#include <SPI.h>
 
 int buttonState = 0;
 const int bp=M2;
void setup(){
   Robot.begin(); // initialize the library
      pinMode(bp, INPUT);     
}

void loop(){
     buttonState = digitalRead(bp);
      if (buttonState == HIGH) {     
   Robot.motorsWrite(50,50);
   
      }
   else {
   Robot.motorsWrite(0,0); // stop moving
   

   }
      }

Thank you.

I do not understand what you want.

What type of sensor?

What type of motor?

Give a full description of your equipment and what you want to happen.

Weedpharma