Can not make work two digitalPinToInterrupt on nano.
One or another works well.
RoofSensor and all application does work for few months.
Trying to add one more WindGuage and even setup() doesn't work (at the end of setup it should be message "Program started", bit no message when two digitalPinToInterrupt in setup().
Could you please help with my problem
#include <SoftwareSerial.h>
//#include <OneWire.h>
#include <stdio.h>
//Pronting to Bluetooth or defailt Serial ports
#define BT
//Define LED Modes and initiate LED variables
#define Led_OFF 0b0000000000000000
#define Led_ON 0b1111111111111111
#define Led_1_1 0b0101010101010101
#define Led_1_3 0b0001000100010001
#define Led_3_1 0b0111011101110111
#define Led_1_7 0b0000000100000001
#define Led_7_1 0b0111111101111111
#define Led_1_15 0b0000000000000001
#define Led_15_1 0b0111111111111111
#define Led_2_2 0b0011001100110011
#define Led_2_6 0b0000001100000011
#define Led_6_2 0b0011111100111111
#define Led_2_14 0b0000000000000011
#define Led_14_2 0b0011111111111111
#define Led_4_4 0b0000111100001111
#define Led_4_12 0b0000000000001111
#define Led_12_4 0b0000111111111111
#define Led_8_8 0b0000000011111111
unsigned int LED_Mode = Led_OFF; //Variable keeps currnet LED mode
unsigned int oldLED_Mode = Led_ON; //Variable keeps previous LED mode
byte LED_Status = LED_Mode & 0b1; //Variable keeps currnet LED status
//Programm will curcle with left shift LED_Mode on each programm loop
#define WindGuage 2 // Wind speed guage based on Interruptins(Interruptions allowed only on D2 and D3)
// Count rotates of the Wind Guage (for future use)
#define RoofSensor 3 // RoofSensor to Interrupt and status (Interruptions allowed only on D2 and D3)
// LOW - Roof opened; HIGH - Roof Closed
#define RainSensorPower 4 // Reserved Powering RainSensor on demand
#define RainSensor 5 // Rain Sensor Digital input.
// Pin is LOW when precipitation detected
#define OneWirePin 6 // OneWire Pin (CURRENTLY NOT IN USE)
#define BTSerialRX 7 // BlueTooth RX Pin - the pin on which Arduino to receive serial data
#define BTSerialTX 8 // BlueTooth TX Pin - the pin on which Arduino to transmit serial data
#define ActuatorRetButton 10 // Switch or Button for Activating Retraction of Actuatorunsigned (PULLED UP, Low when pressed)
#define ActuatorExtButton 11 // Switch or Button for Activating Extraction of Actuator (PULLED UP, Low when pressed)
// Keep pressed to use ControlPower to Open andd Close the Roof
#define ControlPower 12 // Control Power Source (5V - 12V) Status.
// Pin is LOW when Power is OK.
#define StatusLED 13 // Buildin Status LED
#define ActuatorRet A0 // Actuator Retraction to Relay 1 (with two Normal-Closed Micro Switches for Emergency Stop Retraction)
// "+" on Actuator Connector
#define ActuatorExt A1 // Actuator Extraction to Relay 2 (with embedded in Actuator Full Extraction Auto Stop Switch)
// "-" on Actuator Connector
#define Locker A2 // Roof locker to Relay 3
#define Reserved A3 // Reserved to Relay 4 (NOT IN USE)
#define RetPower A7 // Status received back from IN1 of Relay Module (Retraction Power). Not always accurate
// <10 - Roof is closing; <1023 - Roof is closed; =1023 - Roof is opened
#define LoopDelay 100 //Milliseconds of delay between program loops
float LoopDurartion = (float)LoopDelay/1000; //Milliseconds of delay between program loops
byte MaxExtractionDuration = 90; //Maximum duration of Actuator Extraction in seconds
byte MaxRetractionDuration = 90; //Maximum duration of Actuator Retraction in seconds
unsigned int MaxExtractionLoops = MaxExtractionDuration/LoopDurartion; //Maximum duration of Actuator Move in programm loops
unsigned int MaxRetractionLoops = MaxRetractionDuration/LoopDurartion; //Maximum duration of Actuator Move in programm loops
unsigned int RemainActuatorLoops; //How many programm loops ramain before stop Actuator
unsigned int RecoveryDelay = 10; //Recovery time for failed power or Trigered Rain Sensor in seconds
unsigned int RecoveryLoops = RecoveryDelay/LoopDurartion; //Recovery time for failed power or Trigered Rain Sensor in programm loops
unsigned int RemainRecoveryLoops; //How many programm loops remain before Actuator can be used
unsigned int ReinSensorSleepTimer = 15; //Sleep timer in seconds for Rain Sensor when Roof Closed to reduce Sensor corrosion
//Should be higher than RecoveryDelay as during it could be sent to sleep during recovery
unsigned int ReinSensorSleepLoops = ReinSensorSleepTimer/LoopDurartion; //Sleep timer in loops for Rain Sensor when Roof Closed to reduce Sensor corrosion
unsigned int ReinSensorWakeUpTimer = 600; //WakeUp timer in seconds for Rain Sensor when Roof Closed to periodically check Rain Sensors
unsigned int ReinSensorWakeUpLoops = ReinSensorWakeUpTimer/LoopDurartion;//WakeUp timer in loops for Rain Sensor when Roof Closed to periodically check Rain Sensors
unsigned int ReinSensorSleepTracker = 0; //Counter the loops RainSensor Active after the Roof closed and sensor does not sleep
unsigned int ReinSensorWakeUpTracker = 0; //Counter the loops RainSensor Inactive to wake it up and check is Rain
boolean RainSensorMemory = HIGH; //To remember last Rain status when sendor is sleeping
unsigned int ReportFrequince = 1; //Reports frequince in Seconds
unsigned int ReportFrequinceLoops = ReportFrequince/LoopDurartion; //Reports frequince in Loops
unsigned int ReportFrequinceTracker = 0; //Coonter the loops from previous report
boolean RoofClosed = true; //Keep previous Roof status. Consider Roof Closed when controller started
boolean NormalOperations = true; //Tracking operation mode by checking ControlPower and Precipoitation Sensor
#define DUMMY 0 //No roof operation
#define BUTTON 1 //Operation activated by Button
#define COMMAND 2 //Operation activated by Command
#define INTERRUPT 3 //Operation activated by Interruntion
char ActivationType = DUMMY; //Activation type: 0 - No ongoing operations; 1 - Activated by Button; 2 - Activated by Command; 3 - Interruption happened
SoftwareSerial BTSerial (BTSerialRX,BTSerialTX); //00:14:03:05:5a:52
void setup() {
//Initializing Pins
//Relays at first
pinMode(ActuatorRet, OUTPUT);
digitalWrite(ActuatorRet, HIGH);
pinMode(ActuatorExt, OUTPUT);
digitalWrite(ActuatorExt, HIGH);
pinMode(Locker, OUTPUT);
digitalWrite(Locker, HIGH);
pinMode(Reserved, OUTPUT);
digitalWrite(Reserved, HIGH);
//Other Pins
pinMode(RoofSensor, INPUT_PULLUP);
pinMode(RainSensor, INPUT_PULLUP);
pinMode(WindGuage, INPUT_PULLUP);
pinMode(RainSensorPower, OUTPUT);
digitalWrite(RainSensorPower, HIGH);
//OneWire ds(OneWirePin);
pinMode(RetPower, INPUT);
pinMode(ActuatorRetButton, INPUT_PULLUP);
pinMode(ActuatorExtButton, INPUT_PULLUP);
pinMode(ControlPower, INPUT_PULLUP);
pinMode(StatusLED, OUTPUT);
digitalWrite(StatusLED, LOW);
attachInterrupt(digitalPinToInterrupt(RoofSensor),intRoofClosed,FALLING);
delay(100);
//attachInterrupt(digitalPinToInterrupt(WindGuage),intWindGuage,FALLING);
if (digitalRead(RoofSensor) == HIGH) {
RoofClosed = true;
Lock();
} else {
RoofClosed = false;
}
Serial.begin(9600);
BTSerial.begin(9600);
echo("Program started");
}
void loop() {
....