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

Arduino UNO-Based Interactive Cat Face Display with Servo, Stepper Motor, and Ultrasonic Sensor

View and Edit Project In Cirkit DesignerImage of Arduino UNO-Based Interactive Cat Face Display with Servo, Stepper Motor, and Ultrasonic Sensor

Circuit Documentation

Summary

This project involves an interactive system that uses an Arduino UNO to control various components including a stepper motor, a servo motor, an ultrasonic sensor, a force sensing resistor, a DFPlayer Mini for audio playback, and a relay to control a light bulb. The system detects the presence of an owner using the ultrasonic sensor and changes the cat's face to happy or sad accordingly. It also opens or closes a heart and turns on or off a light based on the force sensor input.

Component List

  1. Stepper Motor (Bipolar)

    • Pins: D, B, C, A
    • Description: A bipolar stepper motor used to open and close a heart.
  2. Force Sensing Resistor

    • Pins: pin 0, pin 1
    • Description: A sensor used to detect force or pressure, such as a pat.
  3. ULN 2003

    • Pins: IN1, IN2, IN3, IN4, IN5, IN6, IN7, GND, +, COIL1, COIL2, COIL3, COIL4, COIL5
    • Description: A Darlington transistor array used to drive the stepper motor.
  4. Arduino UNO

    • 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
    • Description: The main microcontroller used to control the entire system.
  5. BULB

    • Pins: +, -
    • Description: A light bulb controlled by a relay.
  6. 1-Channel Relay (5V 10A)

    • Pins: NC, signal, C, power, NO, ground
    • Description: A relay used to control the light bulb.
  7. HC-SR04 Ultrasonic Sensor

    • Pins: VCC, TRIG, ECHO, GND
    • Description: An ultrasonic sensor used to detect the presence of the owner.
  8. 2x 18650

    • Pins: vcc, gnd
    • Description: A battery pack used to power the Arduino UNO.
  9. Resistor (200 Ohms)

    • Pins: pin1, pin2
    • Description: A resistor used in the circuit.
  10. Resistor (1000 Ohms)

    • Pins: pin1, pin2
    • Description: Another resistor used in the circuit.
  11. AC source

    • Pins: +, -
    • Description: An AC power source.
  12. Micro servo 9G

    • Pins: GND, +5V, PWM
    • Description: A servo motor used to control the cat's face.
  13. Loudspeaker

    • Pins: pin1, pin2
    • Description: A loudspeaker used for audio output.
  14. DFPlayer MINI

    • Pins: VCC, BUSY, RX, USB -, TX, USB +, DAC_R, K2/ADC_KEY, DAC_L, K1/ADC_KEY, SPK1, IO 2, GND, SPK2, IO 1
    • Description: An MP3 player module used to play sounds.

Wiring Details

Stepper Motor (Bipolar)

Force Sensing Resistor

ULN 2003

Arduino UNO

BULB

1-Channel Relay (5V 10A)

HC-SR04 Ultrasonic Sensor

2x 18650

Resistor (200 Ohms)

Resistor (1000 Ohms)

AC source

Micro servo 9G

Loudspeaker

DFPlayer MINI

Code Documentation

/*
 * This Arduino sketch controls a cat face display with a servo motor, a stepper motor
 * for opening and closing a heart, an ultrasonic sensor for detecting the owner's
 * presence, a force sensor for detecting pats, and a DFPlayer Mini for playing
 * sounds. The system changes the cat's face to happy or sad based on the owner's
 * presence and plays corresponding sounds. It also opens or closes the heart and
 * turns on or off a light based on the force sensor input.
 */

#include <Stepper.h>
#include <Servo.h>
#include "SoftwareSerial.h"
#include "DFRobotDFPlayerMini.h"

// Pin Definitions
const int trigPin = 13;
const int echoPin = 12;
const int forceSensorPin = A0;  // Force sensor connected to analog pin A0
const int lightPin = 6;         // Light bulb control pin (Relay or transistor)
const int servoPin = 5;         // Servo motor control pin
const int rxPin = 4;            // RX pin for DFPlayer Mini
const int txPin = 3;            // TX pin for DFPlayer Mini

// Stepper Motor Settings
const int stepsPerRevolution = 2048;  // Adjust this value to match your stepper motor
Stepper stepperMotor(stepsPerRevolution, 8, 10, 9, 11);  // Stepper motor pins

// Servo Motor
Servo catFaceServo;
int catFacePosition = 0;  // Initial position: 0 for sad face, 180 for happy face

// DFPlayer Mini
SoftwareSerial mySerial(rxPin, txPin);  // RX and TX pins for DFPlayer Mini
DFRobotDFPlayerMini myDFPlayer;

// State Variables
bool lightOn = false;     // Tracks if the light is ON or OFF
bool heartOpened = false; // Tracks if the heart is OPEN or CLOSED

void setup() {