Hi PaulS
Thanks again for the feedback.
First things first. Is this implementation of the pullup code from CrossRoads correct?
/*
Fluid Dispenser v1.0
written by : Theo Gresse
Date : 15/10/2012
*/
const int buttonPressPin = 2; //refers to the pin where the button is connected for user input
const int glassSensorPin = 3; //refers to a button that is depressed by the weight of a glass
const int relayOutPin = 13; //refers to the pin being used to trigger the relay
const int delayTime = 1250; //constant value assigned to delayTime, used to keep solenoid valve open
void setup() //setup
{
pinMode(buttonPressPin, INPUT_PULLUP); //buttonPress defined as an input
pinMode(glassSensorPin, INPUT_PULLUP); //glassSensor defined as an input
pinMode(relayOutPin, OUTPUT); //relayOut defined as an output
digitalWrite(buttonPressPin, HIGH); //enabling pull-up resistor on pin 2
digitalWrite(glassSensorPin, HIGH); //enabling pull-up resistor o
}
void loop() //start of loop
{
if (digitalRead(buttonPressPin) == LOW //if the signal from the button is LOW (or pressed)
&& //and
(digitalRead(glassSensorPin) == LOW)) //if the signal from the glassSensor is LOW (or pressed)
{ //then
digitalWrite(relayOutPin, HIGH); //activate the relay
delay(delayTime); //keep relay activated long enough to dispense certain volume
digitalWrite(relayOutPin, LOW); //deactivate the relay
}
else
{
digitalWrite(relayOutPin, LOW); //no button pressed, no action taken, relay deactivated
}
} //end loop