@ AWOL
AWOL:
Is this implementation of the pullup code from CrossRoads correct?
Crossroad's original suggestion was correct.
Your mangling of it is too verbose.
See reply #3, particularly the word "or".
Sorry about that. It was late and I was busy with a tutorial on the pullups on the second part of CrossRoads' suggestion and didn't notice that I already implemented the first suggestion from him.
/*
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 & pullup resistor called
pinMode(glassSensorPin, INPUT_PULLUP); //glassSensor defined as an input & pullup resistor called
pinMode(relayOutPin, OUTPUT); //relayOut defined as an output
}
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
Rectified! (I hope) ![]()