Control Solenoid Valve Using Arduino

Introduction: Control Solenoid Valve Using Arduino

About: hIOTron is an IoT Based company that offers IoT Platforms, IoT Solutions, IoT Training.

This project is how to control the solenoid valve for various applications that can be used to open or close water or gas pipelines.


Arduino Uno

Solenoid 12v



Register 10k ohm

1N4007 Diode


Connecting Wires

Step 1: Project Story

The solenoid is generally used as an actuator in various process automation systems. There are solenoid valves that can be also used to open or close water or gas pipelines.

The Doorbell also has a plunger-type solenoid coil inside it, which when energized by AC power source will shift a small rod up and down.

This rod will hit the metal plates situated on either side of the solenoid to generate the soothing ding dong sound. It is also used as starters in vehicles or as a valve in RO and sprinkler systems.

As we all know solenoid converts electrical energy into mechanical energy that has a coil wound over the conductive material. Generally, we used a 12V solenoid valve which is used in controlling the flow of liquids.

Learn more about IoT Training in Pune which will helps to build Customized IoT Solutions with its practical implementations.

Controlling the Solenoid valve using Arduino:

After updating the complete code into the Arduino, we will be able to turn on and off the solenoid with the help of two pushbuttons. An LED is also connected with solenoid for indication purposes. When we press button 1, Arduino sends a HIGH logic to the gate terminal of the MOSFET IRF540, connected on the 9th pin of the Arduino.

IRF540 is an N-Channel MOSFET, so when its gate terminal gets HIGH, it enables the flow of current from drain to source and turns the solenoid on. Similarly, when we press the button 2, Arduino sends a LOW logic to the gate terminal of the MOSFET IRF540 which turns the solenoid off.

And after completion of all steps, this is the final outcome of the project.

Step 2: Circuit Schematic

Step 3: Run a Program

void setup() {

pinMode(9, OUTPUT);

pinMode(2, INPUT);

pinMode(3, INPUT);


void loop() {






else if(digitalRead(3)==HIGH)






Be the First to Share


    • Make It Bridge

      Make It Bridge
    • Big and Small Contest

      Big and Small Contest
    • Game Design: Student Design Challenge

      Game Design: Student Design Challenge