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

Arduino UNO Controlled Color Sorting Machine with LCD Feedback and Servo Mechanism

View and Edit Project In Cirkit DesignerImage of Arduino UNO Controlled Color Sorting Machine with LCD Feedback and Servo Mechanism

Circuit Documentation

Summary

This circuit is designed to interface an Arduino UNO with various peripherals including an LCD screen, a servo motor, a DC motor via an L298N motor driver, a TCS3200 color sensor, and a relay module. The Arduino UNO serves as the central microcontroller unit, controlling the inputs and outputs to the other components. The LCD screen displays information, the servo motor adjusts positions, the DC motor provides motion, the TCS3200 color sensor detects color, and the relay module switches power to the motor driver. The circuit is powered by a 9V battery.

Component List

Arduino UNO

A microcontroller board based on the ATmega328P. It has 14 digital input/output pins, 6 analog inputs, a 16 MHz quartz crystal, a USB connection, a power jack, an ICSP header, and a reset button.

TCS3200 Color Sensor

A color sensor module that can detect and measure a wide range of colors. It includes output pins and control pins for setting the frequency scaling.

Tower Pro SG90 Servo

A small and lightweight servo motor capable of precise control. It can be used for various applications like steering mechanisms in RC vehicles or robotic arms.

DC Motor

A standard DC motor used for providing rotational motion.

L298N DC Motor Driver

A motor driver module capable of driving two DC motors. It has pins for motor outputs, power supply, and control inputs.

Relay Module 5V-30V

A relay module that can switch high voltages and currents using a low voltage signal from a microcontroller.

9V Battery

A standard 9V battery used as the power source for the circuit.

LCD Screen 16x2 I2C

An alphanumeric liquid crystal display capable of displaying 16 characters per line across 2 lines. It uses the I2C communication protocol.

Wiring Details

Arduino UNO

TCS3200 Color Sensor

Tower Pro SG90 Servo

DC Motor

L298N DC Motor Driver

Relay Module 5V-30V

9V Battery

LCD Screen 16x2 I2C

Documented Code

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <Servo.h>

// Initialize the I2C LCD
LiquidCrystal_I2C lcd(0x27, 16, 2); // Set the LCD I2C address

// Initialize the servo
Servo myservo;

// Define pin connections
const int tcs3200OutPin = 2; // Output from the TCS3200
const int tcs3200S0Pin = 3; // S0 pin of the TCS3200
const int tcs3200S1Pin = 4; // S1 pin of the TCS3200
const int tcs3200S2Pin = 5; // S2 pin of the TCS3200
const int tcs3200S3Pin = 6; // S3 pin of the TCS3200
const int servoPin = 9; // Control pin for servo motor
const int motorDriverIn1 = 10; // IN1 on the L298N
const int motorDriverIn2 = 11; // IN2 on the L298N
const int motorDriverIn3 = 12; // IN3 on the L298N
const int motorDriverIn4 = 13; // IN4 on the L298N
const int relayPin = 8; // Relay control pin

void setup() {
  // Set up the LCD
  lcd.init();
  lcd.backlight();
  lcd.print("Hello, World!");

  // Set up the servo
  myservo.attach(servoPin);
  myservo.write(90); // Set servo to mid-point

  // Set up the TCS3200 pins
  pinMode(tcs3200OutPin, INPUT);
  pinMode(tcs3200S0Pin, OUTPUT);
  pinMode(tcs3200S1Pin, OUTPUT);
  pinMode(tcs3200S2Pin, OUTPUT);
  pinMode(tcs3200S3Pin, OUTPUT);

  // Set frequency scaling to 20%
  digitalWrite(tcs3200S0Pin, HIGH);
  digitalWrite(tcs3200S1Pin, LOW);

  // Set up the motor driver pins
  pinMode(motorDriverIn1, OUTPUT);
  pinMode(motorDriverIn2, OUTPUT);
  pinMode(motorDriverIn3, OUTPUT);
  pinMode(motorDriverIn4, OUTPUT);

  // Set up the relay pin
  pinMode(relayPin, OUTPUT);
  digitalWrite(relayPin, LOW); // Turn off the relay

  // Set initial motor speed and direction
  digitalWrite(motorDriverIn1, LOW);
  digitalWrite(motorDriverIn2, HIGH);
  digitalWrite(motorDriverIn3, LOW);
  digitalWrite(motorDriverIn4, HIGH);
}

void loop() {
  // This is where you would add the code to interact with the components.
  // For example, you could read from the TCS3200, move the servo, display
  // something on the LCD, control the motor, or toggle the relay.
}

This code initializes and controls the various components connected to the Arduino UNO. It sets up the LCD screen, servo motor, TCS3200 color sensor, motor driver, and relay module. The setup() function configures the pins and sets initial states, while the loop() function is left empty for the user to fill with their specific application logic.