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

Arduino Nano-Based Motion-Activated Peristaltic Pump with LED Indicators

View and Edit Project In Cirkit DesignerImage of Arduino Nano-Based Motion-Activated Peristaltic Pump with LED Indicators

Circuit Documentation

Summary

This circuit is designed to control a peristaltic pump using an Arduino Nano, an IR sensor, and a relay. The circuit also includes an LED ring and two individual LEDs (green and blue) for visual feedback. The IR sensor detects motion, and based on its state, the Arduino controls the relay to turn the pump on or off. The LED ring and blue LED provide visual indications when the pump is activated.

Component List

  1. Arduino Nano

    • Description: Microcontroller board based on the ATmega328P.
    • Pins: D1/TX, D0/RX, RESET, GND, D2, D3, D4, D5, D6, D7, D8, D9, D10, D11/MOSI, D12/MISO, VIN, 5V, A7, A6, A5, A4, A3, A2, A1, A0, AREF, 3V3, D13/SCK
  2. IR Sensor

    • Description: Infrared sensor for motion detection.
    • Pins: out, gnd, vcc
  3. 12V Single Channel Relay

    • Description: Relay module for switching high-power devices.
    • Pins: NC, COM, NO, IN, GND, VCC
  4. LED: Two Pin (Green)

    • Description: Green LED for visual indication.
    • Pins: cathode, anode
  5. Resistor (220 Ohms)

    • Description: Resistor to limit current.
    • Pins: pin1, pin2
  6. LED: Two Pin (Blue)

    • Description: Blue LED for visual indication.
    • Pins: cathode, anode
  7. Peristaltic Pump

    • Description: Pump for fluid transfer.
    • Pins: +, -
  8. Rocker Switch

    • Description: Switch to control power.
    • Pins: 1, 2
  9. 4 x AAA Battery Mount

    • Description: Battery holder for 4 AAA batteries.
    • Pins: -, +
  10. Adafruit 12 NeoPixel Ring

    • Description: LED ring with 12 NeoPixels.
    • Pins: OUT, VDD, IN, GND

Wiring Details

Arduino Nano

IR Sensor

12V Single Channel Relay

LED: Two Pin (Green)

Resistor (220 Ohms)

LED: Two Pin (Blue)

Resistor (220 Ohms)

Peristaltic Pump

Rocker Switch

4 x AAA Battery Mount

Adafruit 12 NeoPixel Ring

Code Documentation

#include <Adafruit_NeoPixel.h>

#define LED_RING_PIN 6      // Pin connected to the LED ring data input
#define NUM_LEDS 12         // Number of LEDs on the ring (adjust as per your LED ring)
const int irSensorPin = 2;  // Pin connected to the IR sensor
const int relayPin = 3;     // Pin connected to the relay
const int greenLedPin = 4;  // Pin connected to the green LED (always on)
const int blueLedPin = 5;   // Pin connected to the blue LED

int sensorState = 0;        // Variable to store sensor state

Adafruit_NeoPixel ledRing = Adafruit_NeoPixel(NUM_LEDS, LED_RING_PIN, NEO_GRB + NEO_KHZ800);

void setup() {
  Serial.begin(9600);                // Start serial communication at 9600 baud
  pinMode(irSensorPin, INPUT);       // Set IR sensor as input
  pinMode(relayPin, OUTPUT);         // Set relay as output
  pinMode(greenLedPin, OUTPUT);      // Set green LED as output
  pinMode(blueLedPin, OUTPUT);       // Set blue LED as output
  digitalWrite(greenLedPin, HIGH);   // Turn on green LED (always on)
  digitalWrite(blueLedPin, LOW);     // Initialize blue LED as off
  digitalWrite(relayPin, HIGH);      // Initialize relay to off (pump off by default)
  ledRing.begin();                   // Initialize the LED ring
  ledRing.show();                    // Turn off all LEDs initially
}

void loop() {
  sensorState = digitalRead(irSensorPin);
  Serial.print("Sensor state:");
  Serial.println(sensorState);
  if (sensorState == 1) {            // If sensor does NOT detect motion (HIGH state)
    digitalWrite(relayPin, HIGH);    // Turn off the relay
    turnOffLedRing();                // Turn off the LED ring
  } else {                           // If sensor detects motion (LOW state)
    digitalWrite(relayPin, LOW);     // Turn on the relay
    digitalWrite(blueLedPin, HIGH);  // Turn on blue LED
    lightUpLedRingBlue();            // Light up the LED ring in blue
    delay(500);                      // Keep blue LED on for 0.5 second
    digitalWrite(blueLedPin, LOW);   // Turn off blue LED
    turnOffLedRing();                // Turn off the LED ring
  }
}

void lightUpLedRingBlue() {
  for (int i = 0; i < NUM_LEDS; i++) {
    ledRing.setPixelColor(i, ledRing.Color(0, 0, 255)); // Set LED to blue (R=0, G=0, B=255)
  }
  ledRing.show();
}

void turnOffLedRing() {
  for (int i = 0; i < NUM_LEDS; i++) {
    ledRing.setPixelColor(i, ledRing.Color(0, 0, 0)); // Turn off LED
  }
  ledRing.show();
}

This code initializes the IR sensor, relay, green LED, blue LED, and NeoPixel ring. The main loop reads the state of the IR sensor and controls the relay and LEDs accordingly. When motion is detected, the relay is activated to turn on the pump, and the blue LED and NeoPixel ring are lit up.