button toggle

I'm looking to include a single button press ON and press again for OFF to incorporate into my green house control program (arduino uno) I have Ace Button installed within my sketch but this program doesn't seem to give a button toggle feature. Any ideas please

(deleted)

Spycatcher here is my code:-

#include "DHT.h"
#define DHTPIN 4     // pin 4 sensor is connected to
#define DHTTYPE DHT22   // DHT 22  (AM2302)

                            // motor (1) door control motor = in1,in2,enA
int in1 = 12;
int in2 = 11;
int enApin = 10;
int vent = 9;               // window vent
int fan = 8;                // vent fan 
int buttonLpin = 6;                // left side door switch
int buttonRpin = 5;               // right hand door switch
int val = 0;
const int buttonpin = 3;    // Arduino interrupt pin & door lock open switch
const int dooraPin = 2;     // input door open button

//Variables
volatile int buttonState = 0;  
int maxTemp2 = 28;     // max set at 28  for door
int minTemp2 = 26;     // min set at 24   "    "
int maxTemp = 18;      // max set at 18  for vent
int minTemp = 15;      // min set at 15  for vent
int maxHum  = 60;
int minHum  = 55; 

DHT dht(DHTPIN, DHTTYPE);

void setup() {

  pinMode (vent, OUTPUT);
  pinMode (dooraPin, INPUT); // open door switch
  pinMode (enApin, OUTPUT);
  pinMode (in1, OUTPUT);
  pinMode (in2, OUTPUT);
  pinMode (fan, OUTPUT);
  pinMode (buttonLpin, INPUT);         // left door switch 
  pinMode (buttonRpin, INPUT);         // right door switch  
  pinMode (buttonpin, INPUT);   //INPUT_PULLUP); =  no resistor to 5 v+ (door open switch)
  attachInterrupt(1, pin_ISR,LOW);     // ============ (1) = pin 3 (0) = pin  2...
  Serial.begin(9600); 
  dht.begin();

}
void loop() {
 
 // ===================================open door door button=================================
//  val = digitalRead(dooraPin);   // read the door open button ( HIGH on press)  if (val = digitalRead,doora) {
//  digitalWrite(enApin, val);           // sets the output to the inputs value
 // digitalWrite(in1, HIGH);        // door  motor  >>>> OPEN   pin 12
 // digitalWrite(in2, LOW);        //  "      "     "     "  pin 11
 //   val = digitalRead(buttonLpin);     // read the left door input pin
 //   digitalWrite(enApin, val); 
 //  delay (8000);                     // hold open door for ? seconds
 //  digitalWrite(enApin, LOW);         
//  digitalWrite(in1, HIGH);         // door  motor  <<<<< CLOSE  pin 12   
//  digitalWrite(in2, HIGH);         //  "      "     "     "  pin 11 
//    val = digitalRead(buttonRpin);   //  read right door limit switch
// digitalWrite(enApin, val);       //  switch off motor
// }else                                     
   delay(500);                   // Wait a few seconds between measurements.
  // Reading temperature or humidity takes about 250 milliseconds!
  // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
  float h = dht.readHumidity();
  // Read temperature as Celsius
  float t = dht.readTemperature();
  
  // Check if any reads failed and exit early (to try again).
  if (isnan(h) || isnan(t)) {
    Serial.println("Failed to read from DHT sensor!");
    return;
  }
                  // ============================== VENT CHECK ============
    if(t > maxTemp) {
     digitalWrite(vent, HIGH);
  } else
    if(t < minTemp) {                           // if(h < minHum || t < minTemp) {
     digitalWrite(vent, LOW); 
                 // =============================== DOOR CHECK (temp2) OPENING FOR HIGH TEMPERATURE
  }
     if(t > maxTemp2) {
     val = digitalRead(buttonLpin);     // read the input pin
    digitalWrite(enApin, val);           // sets the output to the inputs value
    digitalWrite(in1, HIGH);        // door  motor  >>>> OPEN   pin 12
    digitalWrite(in2, LOW);        //  "      "     "     "  pin 11
   
               // ======================================= door closing / for temp2 = LOW TEMPERATURE
  } else 
    if(t < minTemp2) {
   val = digitalRead(buttonRpin);     // read the input pin
   digitalWrite(enApin, val);           // sets the output to the inputs value
   digitalWrite(in1, LOW);         // door  motor  >>>> CLOSE  pin 12   
   digitalWrite(in2, HIGH);       //  "      "     "     "  pin 11     
 
  }            //=================== checking humidity sensors to control fan if high fan on
   if(h > maxHum) {
    digitalWrite(vent, HIGH);
    digitalWrite(fan, HIGH);
  } else
    if(h < minHum) {
    digitalWrite(fan, LOW);
  }  
  Serial.print("Humidity: "); 
  Serial.print(h);
  Serial.print(" %\t");
  Serial.print("Temperature: "); 
  Serial.print(t);
  Serial.println(" *C ");  
  }
  void pin_ISR() {                //======================= door lock switch ISR============ 
                                             //  
  val = digitalRead(buttonpin);   // reading button pin & writing to output (door lock switch ON or OFF)===========
  digitalWrite(in1, HIGH), val; 
  digitalWrite(in2, LOW), val;   
  val = digitalRead(buttonLpin);     // read the input pin
  digitalWrite(enApin, val);         // sets the output to the inputs value to cancel motor drive at limit switch
   
}

This is a recurring theme. Try a site search on ‘push on push off’.

I see an interrupt function in there!

That is always a worry!

Yes. Don't use interrupts for switches, poll these in the loop() instead.
To create a toggle function from a push button, you can have a global bool status variable with an initial value of false. The push button then inverts the current value of the status variable. It is basically this:

bool toggle = false ; // global or static

. . . 

if (digitalRead( togglePin )  toggle = ! toggle ;   // some debouncing also would be nice here

Look at the StateChangeDetection example in the IDE