Cirkit Designer Logo
Cirkit Designer
Your all-in-one circuit design IDE
Home / 
Project Documentation

Arduino-Controlled Solenoid Driver with pMOS Transistor

Image of Arduino-Controlled Solenoid Driver with pMOS Transistor

Circuit Documentation

Summary

This circuit is designed to control a solenoid using an Arduino UNO and a pMOS transistor. The solenoid is actuated by toggling the gate of the pMOS transistor with a digital output from the Arduino. A resistor is used to limit the current to the gate, and a diode is placed across the solenoid to protect against voltage spikes caused by the inductive load when the solenoid is turned off.

Component List

Arduino UNO

  • Description: A microcontroller board based on the ATmega328P.
  • Purpose: Acts as the control unit for the solenoid, providing the switching signal to the pMOS transistor.

pMOS Transistor (MOSFET)

  • Description: A type of MOSFET that conducts when the gate voltage is lower than the source voltage.
  • Purpose: Used as a switch to control the power to the solenoid.

Resistor

  • Description: A passive two-terminal electrical component that implements electrical resistance.
  • Value: 10,000 Ohms
  • Purpose: Limits the current to the gate of the pMOS transistor.

Diode

  • Description: A semiconductor device that allows current to flow in one direction only.
  • Purpose: Protects the circuit from voltage spikes when the solenoid is deactivated.

Solenoid

  • Description: An electromagnetic actuator that converts electrical energy into mechanical motion.
  • Purpose: The load being controlled by the circuit, actuated by the pMOS transistor.

Wiring Details

Arduino UNO

  • 5V: Connected to the source of the pMOS transistor.
  • GND: Connected to the anode of the diode and one pin of the solenoid.
  • D9: Connected to the gate of the pMOS transistor through a 10k Ohm resistor.

pMOS Transistor (MOSFET)

  • Gate: Connected to pin D9 of the Arduino UNO through a 10k Ohm resistor.
  • Drain: Connected to one pin of the solenoid and the cathode of the diode.
  • Source: Connected to the 5V supply from the Arduino UNO.

Resistor

  • Pin1: Connected to the gate of the pMOS transistor.
  • Pin2: Connected to pin D9 of the Arduino UNO.

Diode

  • Cathode: Connected to the drain of the pMOS transistor and one pin of the solenoid.
  • Anode: Connected to GND on the Arduino UNO.

Solenoid

  • Pin1: Connected to GND on the Arduino UNO and the anode of the diode.
  • Pin2: Connected to the drain of the pMOS transistor and the cathode of the diode.

Documented Code

/*
  Solenoid Control with Arduino and pMOS Transistor

  This sketch controls a solenoid via a pMOS transistor. The solenoid is turned on and off
  every second. The pMOS transistor is driven by pin 9 of the Arduino. When the pin is set to LOW,
  the pMOS transistor allows current to flow through the solenoid, activating it. When the pin is
  set to HIGH, the pMOS transistor cuts off the current, deactivating the solenoid.

  Circuit connections:
  - Gate of pMOS transistor connected to pin 9 through a resistor.
  - Source of pMOS transistor connected to +5V.
  - Drain of pMOS transistor connected to one end of the solenoid.
  - Other end of the solenoid connected to GND.
  - Diode across the solenoid with the anode to GND and cathode to the solenoid's connection to the pMOS drain.
*/

int solenoidPin = 9; // Output pin on the Arduino connected to the gate of the pMOS transistor

void setup() {
  pinMode(solenoidPin, OUTPUT); // Set solenoidPin as an output
}

void loop() {
  digitalWrite(solenoidPin, LOW);  // Turn the solenoid ON by setting the pMOS gate to LOW
  delay(1000);                     // Wait 1 second
  digitalWrite(solenoidPin, HIGH); // Turn the solenoid OFF by setting the pMOS gate to HIGH
  delay(1000);                     // Wait 1 second
}

This code is designed to be uploaded to the Arduino UNO microcontroller. It sets up pin D9 as an output and toggles it every second to control the solenoid via the pMOS transistor.