How to make Automatic Liquid Soap Dispenser

 







            CODE 

// Pin configuration

const int irSensorPin = 2; // IR sensor connected to pin 2

const int relayPin = 8;    // Relay module connected to pin 8

const int ledPin = 9;      // LED connected to pin 9


void setup() {

  pinMode(irSensorPin, INPUT);   // IR sensor pin as input

  pinMode(relayPin, OUTPUT); // Relay pin as output

  pinMode(ledPin, OUTPUT);   // LED pin as output

}


void loop() {

  int sensorValue = digitalRead(irSensorPin); // Read the value from IR sensor


  if (sensorValue == HIGH) {

    digitalWrite(ledPin, HIGH);    // Turn on LED

    digitalWrite(relayPin, HIGH);  // Turn on relay

  } else {

    digitalWrite(ledPin, LOW);     // Turn off LED

    digitalWrite(relayPin, LOW);   // Turn off relay

  }

}

Post a Comment

Previous Post Next Post

Contact Form