Hoping that someone can help a newbie out here. I am having problems with my attachInterrupt button. When I connect the digital pins #2 and #3 up to 5V and then run the button to a ground to clear out to 0V for the LOW nothing is happening on my LCD. The "regular" code just keeps on running with no interruption. Could someone with more then a newbie status like me help me out.
Thank you in advance!!!
//Read air pressure in air bags, 4 air pressure sensors on analog pins 0-3
//2 tank sensors connected to analog pins 4,5
//Air ride control unit attached to digital pin 13-6
//2 Push buttons connected digital Pins 2,3 to interrupt and clear display for upper and lower tank
//2 Push buttons connected digital Pins 5,4 to set ride heights
//Uses moderndevice 20x4 LCD screen
const int psisensor1 = 0; //Set LF Bag sensor input on Analog port 0
const int psisensor2 = 1; //Set RF Bag Sensor input on Analog port 1
const int psisensor3 = 2; //Set LR Bag Sensor input on Analog port 2
const int psisensor4 = 3; //Set RR Bag Sensor input on Analog port 3
const int tank1sensor = 4; //Set Upper Tank Sensor input on Analog port 4
const int tank2sensor = 5; //Set Lower Tank Sensor input on Analog Port 5
int sensor1val = 0; //Set LF Bag sensor to 0 value
int sensor2val = 0; //Set RF Bag sensor to 0 value
int sensor3val = 0; //Set LR Bag Sensor to 0 value
int sensor4val = 0; //Set RR Bag Sensor to 0 value
int tank1val = 0; //Set Upper Tank sensor to value 0
int tank2val = 0; //Set Lower Tank sensor to value 0
int press1 = 0;
int press2 = 0;
int press3 = 0;
int press4 = 0;
volatile int tank1pres = 0; //Set tank 1 pressure to 0
volatile int tank2pres = 0; //Set tank 2 pressure to 0
const int lfupPin = 13; //LF Bag fill solenoid to Digital Pin 13
const int lfdownPin = 12; //LF Bag release solenoid to Digital Pin 12
const int rfupPin = 11; //RF Bag fill solenoid to Digial Pin 11
const int rfdownPin = 10; //RF Bag release solenoid to Digital Pin 10
const int lrupPin = 9; //LR Bag fill solenoid to Digital Pin 9
const int lrdownPin = 8; //LR Bag release solenoid to Digital Pin 8
const int rrupPin = 7; //RR Bag fill solenoid to Digital Pin 7
const int rrdownPin = 6; //RR Bag release solenoid to Digital Pin 6
const int upbuttonPin = 5; //Push button to put car at highes level on Digital Pin 5
const int ridebuttonPin = 4; //Push button to put car at ride height on Digital Pin 4
int upbuttonState = LOW; // the current state of the output pin
int button1State; // the current reading from the input pin
int lastButton1State = HIGH; // the previous reading from the input pin
int ridebuttonState = LOW;
int button2State;
int lastbutton2State = HIGH;
long lastDebounceTime = 0;
long debounceDelay = 50;
boolean tank1_print, tank2_print;
void setup()
{
Serial.begin(9600);
attachInterrupt(0, tank1, LOW);
attachInterrupt(1, tank2, LOW);
pinMode (lfupPin, OUTPUT);
pinMode (lfdownPin, OUTPUT);
pinMode (rfupPin, OUTPUT);
pinMode (rfdownPin, OUTPUT);
pinMode (lrupPin, OUTPUT);
pinMode (lrdownPin, OUTPUT);
pinMode (rrupPin, OUTPUT);
pinMode (rrdownPin, OUTPUT);
pinMode (upbuttonPin, INPUT);
pinMode (ridebuttonPin, INPUT);
Serial.print("?f"); //clear LCD per LCD117 command
Serial.print("?x03?y0Rhodes Caddy");
Serial.print("?x03?y11950 Cadillac");
Serial.print("?x00?y3Custom Built by Andy");
delay (5000);
Serial.print("?f"); //clear LCD per LCD117 command
Serial.print("?x02?y0LF PSI:"); // print at column 4, row 1
Serial.print("?x12?y0RF PSI:"); //print at column 13, row 1
Serial.print("?x02?y2LR PSI:"); //print at column 4, row 3
Serial.print("?x12?y2RR PSI:"); //print at column 13, row 3
}
void loop()
{
sensor1val = analogRead(psisensor1); //reads all pressures in 4 bags
press1 = (sensor1val*35.0877-9.4737);
sensor2val = analogRead(psisensor2);
press2 = (sensor2val*35.0877-9.4737);
sensor3val = analogRead(psisensor3);
press3 = (sensor3val*35.0877-9.4737);
sensor4val = analogRead(psisensor4);
press4 = (sensor4val*35.0877-9.4737);
Serial.print("?x03?y1");
Serial.print(press1);
Serial.print("?x13?y1");
Serial.print(press2);
Serial.print("?x03?y3");
Serial.print(press3);
Serial.print("?x13?y3");
Serial.print(press4);
delay(350);
if (tank1_print)
{
Serial.print("?x05?y0");
Serial.print("UPPER TANK PSI:");
tank1val = analogRead(tank1sensor);
tank1pres =(tank1val*35.0877-9.4737);
Serial.print("?x08?y1");
Serial.print(tank1pres);
tank1_print = false;
}
if (tank2_print)
{
Serial.print("?x05?y2");
Serial.print("LOWER TANK PSI:");
tank2val = analogRead(tank2sensor);
tank2pres =(tank2val*35.0877-9.4737);
Serial.print("?x08?y3");
Serial.print(tank2pres);
tank2_print = false;
}
if (digitalRead(upbuttonPin)== HIGH)
{
if (press1 < 116);
{
delay(50);
digitalWrite(lfupPin, HIGH);
if (press1 >115);
{
delay(50);
digitalWrite(lfdownPin, HIGH);
}
}
if (press2 < 116);
{
delay(50);
digitalWrite(rfupPin, HIGH);
if (press2 > 115);
{
delay(50);
digitalWrite(rfdownPin, HIGH);
}
}
if (press3 < 116);
{
delay(50);
digitalWrite (lrupPin, HIGH);
if (press3 > 115);
{
delay(50);
digitalWrite (lrdownPin, HIGH);
}
}
if (press4 < 116);
{
delay(50);
digitalWrite(rrupPin, HIGH);
if (press4 > 115);
{
delay(50);
digitalWrite(rrdownPin, HIGH);
}
}
return;
}
if (digitalRead(ridebuttonPin) == HIGH)
{
if (press1 < 80);
{
delay(50);
digitalWrite (lfupPin, HIGH);
if (press1 > 80);
{
delay(50);
digitalWrite (lfdownPin, HIGH);
}
}
if (press2 < 80);
{
delay(50);
digitalWrite(rfupPin, HIGH);
if (press2 > 80);
{
delay(50);
digitalWrite(rfdownPin, HIGH);
}
}
if (press3 < 80);
{
delay(50);
digitalWrite(lrupPin, HIGH);
if (press3 > 80);
{
delay(50);
digitalWrite(lrdownPin, HIGH);
}
}
if (press4 < 80);
{
delay(50);
digitalWrite(rrupPin, HIGH);
if (press4 > 80);
{
delay(50);
digitalWrite(rrdownPin, HIGH);
}
}
return;
}
int reading1 = digitalRead(upbuttonPin);
if (reading1 != lastButton1State)
{
lastDebounceTime = millis();
}
if ((millis() - lastDebounceTime) > debounceDelay)
{
button1State = reading1;
}
digitalWrite(upbuttonPin, button1State);
lastButton1State = reading1;
int reading2 = digitalRead(ridebuttonPin);
if (reading2 != lastbutton2State)
{
lastDebounceTime = millis();
}
if ((millis() - lastDebounceTime) > debounceDelay)
{
button2State = reading2;
}
digitalWrite(ridebuttonPin, button2State);
lastbutton2State = reading2;
}
void tank1() //Interrupt Button on digital pin 2 to show Tank 1 Pressure
{
tank1_print = true;
}
void tank2() //Interrupt Button on digital pin 3 to show Tank 2 pressure
{
tank2_print = true;
}