hi all I must say I'm loving the Arduino world I'm a newbie and I have managed to create what I was
looking for but could do with a little bit of help and advice.
I needed a alarm system for my boat where I have 2 float switches 1 in the foul tank for when it gets full and 1 for the clean water tank when its nearly empty each float switch sets of a alarm controlled by a dual relay module. I have managed to get the float switches working and each setting off in1 and in2 on the relay module but what I could do with help with is someone just looking over my sketch to see how it looks and if anything needs smoothing out.
I also would like some help in adding a push button delay I know a delay will kill the board all the time its activated but that does not worry me I have googled how to do it but some of it just isn't making sense to me like does it need to be in any sort of sequence on the loop or can it go anywhere? I have read about millis but not sure if this is what I need I would like the delay to be for an hour or 2 any help would be appreciated.
thanks in advance
Daniel
// constants won't change. They're used here to
// set pin numbers:
const int buttonPin = 2;
const int relay = 10;
const int buttonPin1 = 3;
const int relay1 = 11;
// variables will change:
int buttonState = 0; // variable for reading the pushbutton status
void setup() {
pinMode(relay, OUTPUT);
pinMode(relay1, OUTPUT);
pinMode(buttonPin, INPUT);
pinMode(buttonPin1, INPUT);
}
void loop() {
buttonState = digitalRead(buttonPin);
// check if the pushbutton is pressed.
// if it is, the buttonState is HIGH:
if (buttonState == LOW) {
// turn LED on:
digitalWrite(relay, HIGH);
} else {
// turn LED off:
digitalWrite(relay, LOW);
} {
buttonState = digitalRead(buttonPin1);
if (buttonState == LOW) {
digitalWrite(relay1, HIGH);
} else {
digitalWrite(relay1, LOW);
}
}
}
Workingfloatalarm.ino (1.38 KB)