how to control an engine direction with a relay


i’ve been doing a domotic house and im making automatic garage doors.

the problem is i cant mount them but not download them because the engine only works in 1 direction. i need help for making it spin in the other direction. Here’s the code;

 int portagaratge=9;
int boton=8;
void setup (){
  pinMode(portagaratge, OUTPUT);
  pinMode(boton, INPUT);
void loop(){
  if (digitalRead(8)== HIGH){
  digitalWrite(portagaratge, HIGH);
    digitalWrite(portagaratge, LOW);

How could i use a rele to make it spin the other way? thanks

Can use a DPDT relay for direction control, and a separate SPST for power on/off.