hello I was on here about a week ago with a problem ..I had an interrupt not firing well cattledog helped me figure it out ..well I left this project alone for a little while well i decided to revisit the project
and now it is doing the same thing one of my interrupts won't fire and Im sure everything is the same
well here is the code please tell me if you see any mistakes cuz i don't think anything is different
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <avr/interrupt.h>
#include <avr/io.h>
#include <util/delay.h>
#include <Adafruit_ADS1015.h>
Adafruit_ADS1115 ads(0x48);
int16_t adc0; // we read from the ADC, we have a sixteen bit integer as a result
LiquidCrystal_I2C lcd(0x3f, 20,4);
int flag = 0;
int sensorValue=0;
float voltage=0,v1=0,v2=0;
void setup()
{
DDRD = 0b00000000;
lcd.begin(16,2); // initialize the lcd added and works
lcd.init(); // initialize the lcd
lcd.init();
lcd.backlight();
}
void loop()
{
EIMSK =0x3; // Turns on INT0 and INT1
//****************************INT1**********************************************************INT1
PORTD|= (1 << PORTD3); // turn On the Pull-up PD3 is now an input with pull-up enabled
EICRA = (1 << ISC11) | (1 << ISC10); // set INT1 to trigger on rising edge
//****************************INT0**********************************************************INT0
PORTD|= (1 << PORTD2); // turn On the Pull-up PD3 is now an input with pull-up enabled
EICRA = (1 << ISC01) | (0 << ISC00); // set INT0 to trigger on falling edge
//******************************************************************************************
if (flag == 1)
{
adc0 = ads.readADC_SingleEnded(0);
voltage = (adc0 * 0.1875)/1000;
lcd.setCursor(0,0);
lcd.print("A0=");
lcd.print(voltage,5);
lcd.setCursor(8,0);
lcd.print(" Falling ");
delay(100);
flag = 0;
}
//****************************
if (flag == 2)
{
adc0 = ads.readADC_SingleEnded(0);
voltage = (adc0 * 0.1875)/1000;
lcd.setCursor(0,1);
lcd.print("A0=");
lcd.print(voltage,5);
lcd.setCursor(8,1);
float hyst;
if(v1>v2){v1-v2; lcd.setCursor(0,3); lcd.print("Hyst=");lcd.print(v1);}
if(v1<v2){v2-v1; lcd.setCursor(0,3); lcd.print("Hyst=");lcd.print(v2);}
lcd.print(" Rising ");
delay(100);
flag = 0;
}
sei(); // turn on interrupts
}//END OF LOOP
//*************INT1************
ISR (INT1_vect)
{
flag = 1;
}
//*****END-OF-ISR**************
//*************INT0************
ISR (INT0_vect)
{
flag = 2;
}
//*****END-OF-ISR**************