Help with using code for motor controller

I am using a code to power an Arduino UNO with a touch and infrared sensor but I am having trouble connecting it to my motor controller. I used this diagram https://i.ytimg.com/vi/0RLAivgppBM/maxresdefault.jpg to connect my DC motor but I do not know how to incorporate this into my code. My current code is

 // Henry's Bench
// Capacitive Touch Sensor Tutorial

// When Sig Output is high, touch sensor is being pressed
#define ctsPin 2 // Pin for capactitive touch sensor
int LDR = 0;
int ledPin = 13; // pin for the LED

void setup() {
  Serial.begin(9600);
  pinMode(ledPin, OUTPUT);
  pinMode(ctsPin, INPUT);
  pinMode(LDR, INPUT);
}

void loop() {
  int ctsValue = digitalRead(ctsPin);
  if (ctsValue == HIGH) {
    digitalWrite(ledPin, HIGH);
    Serial.println("TOUCHED");
  }
  else {
    digitalWrite(ledPin, LOW);
    Serial.println("not touched");
  }
  delay(200);
  int v = analogRead(LDR);
  Serial.println(v);
}

With the code I would like my DC motor to be able to be turned off and on by the touch and infrared sensors.

Have you a short program that just controls the motor without needing any external input - perhaps 5 seconds in one direction followed by 5 secs in the other direction.

If not, get that working first.

If you need help you need to provide details of your motor and motor driver and the motor power supply.

...R