Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Arduino-Controlled Solenoid Driver with pMOS Transistor

View and Edit Project In Cirkit DesignerImage 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

pMOS Transistor (MOSFET)

Resistor

Diode

Solenoid

Wiring Details

Arduino UNO

pMOS Transistor (MOSFET)

Resistor

Diode

Solenoid

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.