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

Arduino Mega 2560 Based Line-Following Nurse Staff Robot with Ultrasonic Sensors and RGB LED Matrix

View and Edit Project In Cirkit DesignerImage of Arduino Mega 2560 Based Line-Following Nurse Staff Robot with Ultrasonic Sensors and RGB LED Matrix

Circuit Documentation

Summary

The circuit design is for a 2-Wheeled Nurse Staff Robot, which is a line-following robot equipped with various sensors and actuators. The robot is designed to respond to button presses, follow lines, detect colors, interact with obstacles, and provide audio feedback. It features an Arduino Mega 2560 as the central microcontroller, infrared sensors for line tracking, ultrasonic sensors for obstacle detection, a color sensor, a motor driver for wheel control, an RGB LED matrix for visual feedback, a speaker for audio output, and pushbuttons for user interaction.

Component List

Microcontroller

Sensors

Actuators

Power

Miscellaneous

Wiring Details

Arduino Mega 2560

IR Sensors

HC-SR04 Ultrasonic Sensors

TCS3200 Color Sensor

L298N DC Motor Driver

WS2812 RGB LED Matrix 8x8

Loudspeaker

Pushbuttons

Step Down Buck Converter

Resistor

Rocker Switch

Documented Code

The code for the Arduino Mega 2560 is written in C++ and is used to control the robot's behavior. The code is structured into setup and loop functions, with additional functions for specific tasks like moving the motors, detecting colors, and handling button presses.

#include <Servo.h>
#include <Adafruit_NeoPixel.h>
#include <SoftwareSerial.h>

// Pin definitions
// MOTORS
#define LEFT_MOTOR_EN 3
#define LEFT_MOTOR_IN1 4
#define LEFT_MOTOR_IN2 5
#define RIGHT_MOTOR_EN 6
#define RIGHT_MOTOR_IN3 7
#define RIGHT_MOTOR_IN4 8
// IR SENSOR
#define IR_SENSOR_LEFT 9
#define IR_SENSOR_RIGHT 10
// COLOR SENSOR
#define COLOR_SENSOR_OUT 11
#define COLOR_SENSOR_S2 12
#define COLOR_SENSOR_S3 13
#define COLOR_SENSOR_S0 22
#define COLOR_SENSOR_S1 23
// ULTRASONIC SENSOR
#define ULTRASONIC_TRIG1 26
#define ULTRASONIC_ECHO1 24
#define ULTRASONIC_TRIG2 27
#define ULTRASONIC_ECHO2 25
#define ULTRASONIC_TRIG3 29
#define ULTRASONIC_ECHO3 28
// BUTTONS
#define BUTTON_RED 37
#define BUTTON_BLUE 39
#define BUTTON_GREEN 41
// HAND SERVO MOTOR
#define SERVO_LEFT_PIN 2
#define SERVO_RIGHT_PIN 2
// LEDS
#define LED_MATRIX_PIN 53
// SPEAKER
#define SPEAKER_RX 31
#define SPEAKER_TX 30

// Constants
#define LED_MATRIX_NUM_PIXELS 64
#define OBSTACLE_DETECTION_INTERVAL 3000

// Global variables
Servo leftServo;
Servo rightServo;
Adafruit_NeoPixel ledMatrix(LED_MATRIX_NUM_PIXELS, LED_MATRIX_PIN, NEO_GRB + NEO_KHZ800);
SoftwareSerial speaker(SPEAKER_RX, SPEAKER_TX);
unsigned long lastObstacleDetectionTime = 0;

void setup() {
  // Initialize motors, sensors, buttons, servos, LED matrix, and speaker
  // Set pin modes and attach servos
  // Initialize LED matrix and speaker
  // Set initial state: stop motors and blink eyes
}

void loop() {
  // Main loop to handle button presses, line following, color detection,
  // storage check, obstacle detection, and servo movement
}

// Additional functions for moving, stopping motors, detecting color,
// checking storage, detecting obstacles, moving servos, blinking eyes,
// setting eyes color, returning to default position, and turning off the robot

This code snippet provides the structure and constants for the robot's operation. The full implementation of each function would control the robot's motors, read sensor data, and manage the robot's interactions with its environment.