Hi a bit about me, I am a carpenter I can make pretty much anything and if I seen it done once I can usually replicate.
also good at negative earth wiring in cars, but when I comes to reading and learning I'm useless lol.
I got my mega last week to see if I could learn.
So I'm looking to automate my dust collection system like the guy from YouTube channel I like to make stuff. iltms_automated_dust_collection/DustCollectionAutomation_v2.ino at master · iliketomakestuff/iltms_automated_dust_collection · GitHub
I intend to use car door lock actuators to open/close the blast gates and a solid state relay to turn on the extractor. for this I have x16 relay to be able to reverse the polarity control 8 blast gates. I found a code to control current sensing (ACS712) on one tool I will need to add some of code below to open the gates in the correct sequence and then to work with 5 separate tools.
So that leads me on to where I need the help, seems quite trivial I need to add a delay to allow the gates and extractor to run on for 10 seconds when the toggle state changes. Delay doesn't work, it seams to turn off anywhere between 5 and 10 seconds. I also have another toggle and requires a different sequence, when I add this to the sketch the switches seam to have there own mind.
thanks in advance
Curt
const int gate1=22; //open-outlet/ toggle switch
const int gateA=23; //close-outlet/ toggle switch
const int gate2=24; //open-drillpress/current sensor1
const int gateB=25; //close-drillpress/current sensor1
const int gate3=26; //open-if gate a or b open
const int gateC=27; //close-if gate a or b open
const int gate4=28; //open-if gate e,f,g or h open
const int gateD=29; //close-if gate e,f, or h open
const int gate5=30; //open-tablesaw/current sensor2
const int gateE=31; //close-tablesaw/current sensor2
const int gate6=32; //open-mitresaw/current sensor3
const int gateF=33; //close-mitresaw/current sensor3
const int gate7=34; //open-mft/current sensor4
const int gateG=35; //close-mft/current sensor4
const int gate8=36; //open-boom/toggle switch/current sensor5
const int gateH=37; //close-boom/toggle switch/current sensor5
const int SSR=39; //power to extractor
const int RF1= 41; //outlet toggle switch
const int RF2= 42; //boom toggle switch
int RF1Read = 0;
int RF2Read = 0;
unsigned long interval = 10000;
unsigned long previousMillis = 0;
unsigned long currentMillis = 0;
void setup()
{
Serial.begin(9600);
pinMode(SSR, OUTPUT);
pinMode(gateA,OUTPUT);
pinMode(gateC,OUTPUT);
pinMode(gateD,OUTPUT);
pinMode(gateH,OUTPUT);
pinMode(gate1,OUTPUT);
pinMode(gate3,OUTPUT);
pinMode(gate4,OUTPUT);
pinMode(gate8,OUTPUT);
digitalWrite(gate1, HIGH);
digitalWrite(gate2, HIGH);
digitalWrite(gate3, HIGH);
digitalWrite(gate4, HIGH);
digitalWrite(gate5, HIGH);
digitalWrite(gate6, HIGH);
digitalWrite(gate7, HIGH);
digitalWrite(gate8, HIGH);
digitalWrite(gateA, HIGH);
digitalWrite(gateB, HIGH);
digitalWrite(gateC, HIGH);
digitalWrite(gateD, HIGH);
digitalWrite(gateE, HIGH);
digitalWrite(gateF, HIGH);
digitalWrite(gateG, HIGH);
digitalWrite(gateH, HIGH);
digitalWrite(SSR, HIGH);
pinMode(RF1, INPUT_PULLUP);
pinMode(RF2, INPUT_PULLUP);
}
void loop()
{
unsigned long currentMillis1 = millis();
RF1Read = digitalRead(RF1);
RF2Read = digitalRead(RF2);
Serial.print("outlet");
Serial.print(RF1Read);
Serial.print(" ");
Serial.print("boom");
Serial.println(RF2Read);
delay(250);
if (RF1Read==LOW)//0
{
digitalWrite(gate1, LOW);//ON
digitalWrite(gate3, LOW);
digitalWrite(SSR, LOW);
// I need to delay the above for 10sec after the state changes
}
if (RF1Read == HIGH) //1
{
digitalWrite(gate1, HIGH);//off
digitalWrite(gate3, HIGH);
digitalWrite(SSR, HIGH);
delay(1000);
digitalWrite(gateA, LOW);//0n
digitalWrite(gateC, LOW);
delay(1000);
digitalWrite(gateA, HIGH);//off
digitalWrite(gateC, HIGH);
while (digitalRead(RF1) ==HIGH); // do nothing until state changes
}
}