how to make an automatic faucet
Now you will not forget to close your faucet or waste water when you pick a soap to wash your hand or face. This project shows you how to make an automatic faucet, you can even use the faucet that water valve damage because of this circuit use solenoid valve to control water.
Electronic components you need:1 Arduino Uno R3
1 TR1 = IRF 540n N channel MOSFET
1 Sensor1 = IR sensor
1 IR1 = IR led
R1 = 10 kilo-ohms
R2 = 100 ohms
R3 = 4.7 kilo-ohms
1 12 volts solenoid valve
12 volts 1 Ampere adapter
The Arduino code is very simple and you don't need to load any special module to make this project works
created 29 Dec. 2008
modified 9 Apr 2012
modified 20 Oct 2017
by easyandworkproject.xyz
by Tom Igoe
This example code is in the public domain.
*/
// These constants won't change. They're used to give names
// to the pins used:
const int analogInPin = A0; // Analog input pin that the ir sensor is attached to
const int analogOutPin = 9; // Analog output pin that the LED is attached to
int sensorValue = 0; // value read from the IR
int outputValue = 0; // value output to the PWM (analog out)
void setup() {
// initialize serial communications at 9600 bps:
Serial.begin(9600);
pinMode(LED_BUILTIN, OUTPUT);
}
void loop() {
// read the analog in value:
sensorValue = analogRead(analogInPin);
// map it to the range of the analog out:
outputValue = map(sensorValue, 0, 1023 , 0, 255);
// change the analog out value:
analogWrite(analogOutPin, outputValue);
// print the results to the serial monitor:
Serial.print("sensor = ");
Serial.print(sensorValue);
Serial.print("\t output = ");
Serial.println(outputValue);
if (sensorValue < 500)
{
digitalWrite(LED_BUILTIN, HIGH);
}
else if (sensorValue > 500)
{
digitalWrite(LED_BUILTIN, LOW);
}
// wait 2 milliseconds before the next loop
// for the analog-to-digital converter to settle
// after the last reading:
delay(500);
}
Change this code from 500 to 600 if you want to increase detector range.
if (sensorValue < 500)
{
digitalWrite(LED_BUILTIN, HIGH);
}
else if (sensorValue > 500)
{
digitalWrite(LED_BUILTIN, LOW);
}
Comments
Post a Comment