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

Arduino UNO-Based Spectrophotometer with LCD Display and Stepper Motor

View and Edit Project In Cirkit DesignerImage of Arduino UNO-Based Spectrophotometer with LCD Display and Stepper Motor

Circuit Documentation

Summary

This circuit is a spectrophotometer system built using an Arduino UNO, an LCD display, a stepper motor, a trimmer potentiometer, a photocell (LDR), resistors, and an LED. The system measures the concentration of a sample by calculating its absorbance using the Beer-Lambert law. The results are displayed on an LCD and the stepper motor is used to move the sample.

Component List

  1. Arduino UNO

    • Description: A microcontroller board based on the ATmega328P.
    • Pins: UNUSED, IOREF, Reset, 3.3V, 5V, GND, Vin, A0, A1, A2, A3, A4, A5, SCL, SDA, AREF, D13, D12, D11, D10, D9, D8, D7, D6, D5, D4, D3, D2, D1, D0
  2. LCD Display (16 pin)

    • Description: A 16x2 character LCD display.
    • Pins: VSS, VDD, VO, RS, R_W, E, DB0, DB1, DB2, DB3, DB4, DB5, DB6, DB7, A, K
  3. Trimmer Potentiometer

    • Description: A variable resistor used to adjust the contrast of the LCD.
    • Pins: leg1, wiper, leg2
    • Properties: Resistance: 10000 Ohms
  4. 28BYJ-48 Stepper Motor

    • Description: A 5V stepper motor used to move the sample.
    • Pins: BLUE, PINK, YELLOW, ORANGE, RED
  5. ULN 2003

    • Description: A Darlington transistor array used to drive the stepper motor.
    • Pins: IN1, IN2, IN3, IN4, IN5, IN6, IN7, GND, +, COIL1, COIL2, COIL3, COIL4, COIL5
  6. Photocell (LDR)

    • Description: A light-dependent resistor used to measure light intensity.
    • Pins: pin 0, pin 1
  7. Resistor (10k Ohms)

    • Description: A resistor used in the voltage divider with the LDR.
    • Pins: pin1, pin2
    • Properties: Resistance: 10000 Ohms
  8. LED: Two Pin (red)

    • Description: A red LED used as the light source.
    • Pins: cathode, anode
  9. Resistor (330 Ohms)

    • Description: A current-limiting resistor for the LED.
    • Pins: pin1, pin2
    • Properties: Resistance: 330 Ohms

Wiring Details

Arduino UNO

LCD Display (16 pin)

Trimmer Potentiometer

28BYJ-48 Stepper Motor

ULN 2003

Photocell (LDR)

Resistor (10k Ohms)

LED: Two Pin (red)

Resistor (330 Ohms)

Code Documentation

#include <LiquidCrystal.h>
#include <Stepper.h>
#include <math.h> // For log10 function

// LCD setup: RS, E, D4, D5, D6, D7
LiquidCrystal lcd(7, 6, 5, 4, 3, 2);

// Stepper Motor settings
const int stepsPerRevolution = 2048;
Stepper myStepper(stepsPerRevolution, 8, 10, 9, 11);

// Pin definitions
const int ledPin = 13; // LED pin
const int ldrPin = A0; // LDR pin

// Beer-Lambert law constants
const float e = 80000.0;     // Molar absorptivity (L/(mol·cm))
const float b = 1.2;         // Path length (cm)
const int P0 = 900;          // Initial light intensity

int ldrValue = 0;            // Variable to store LDR reading
float P = 0.0;               // Light intensity after passing through sample
float A = 0.0;               // Absorbance
float c = 0.0;               // Concentration in mol/L
float cMicro = 0.0;          // Concentration in µmol/L

void setup() {
  Serial.begin(9600);           // Start Serial Monitor
  lcd.begin(16, 2);             // Initialize the LCD (16x2)
  pinMode(ledPin, OUTPUT);      // LED as output
  myStepper.setSpeed(10);       // Stepper speed (in RPM)

  // Initial LCD message
  lcd.setCursor(0, 0);
  lcd.print("Spectrophotometer");
  delay(2000); // Display welcome message
  lcd.clear();
}

void loop() {
  // Step 1: LED on and read LDR
  digitalWrite(ledPin, HIGH);  // Turn on LED
  delay(100);                  // Wait for light stabilization
  ldrValue = analogRead(ldrPin); // Read LDR value (simulate P)
  P = map(ldrValue, 0, 1023, 0, 900); // Map LDR value to light intensity range

  // Calculate Absorbance (A) and Concentration (c)
  if (P > 0) { // Ensure P is not zero to avoid division by zero
    A = log10((float)P0 / P); // Absorbance calculation
    c = A / (e * b);