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

Arduino UNO-Based Touch-Activated Treat Dispenser with OLED Display and Servo Mechanism

View and Edit Project In Cirkit DesignerImage of Arduino UNO-Based Touch-Activated Treat Dispenser with OLED Display and Servo Mechanism

Circuit Documentation

Summary

This circuit is designed to control a servo motor, a buzzer, and an OLED display using an Arduino UNO. The circuit also includes a touch sensor to trigger the servo motor and buzzer. The OLED display shows different messages based on the state of the touch sensor.

Component List

  1. 9V Battery

    • Description: Provides power to the circuit.
    • Pins: +, -
  2. Arduino UNO

    • Description: Microcontroller used to control the components.
    • 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
  3. Touch Sensor

    • Description: Detects touch input to trigger actions.
    • Pins: IO, VCC, GND
  4. Buzzer

    • Description: Emits sound when activated.
    • Pins: PIN, GND
  5. OLED 1.3" Display

    • Description: Displays messages and images.
    • Pins: GND, VCC, SCL, SDA
  6. Rocker Switch

    • Description: Controls the power supply to the Arduino.
    • Pins: 1, 2
  7. Servo Motor

    • Description: Rotates to a specific angle when activated.
    • Pins: GND, VCC, PWM

Wiring Details

9V Battery

Arduino UNO

Touch Sensor

Buzzer

OLED 1.3" Display

Rocker Switch

Servo Motor

Code Documentation

#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SH1106.h>
#include <Servo.h>

// OLED display setup
#define OLED_RESET -1
Adafruit_SH1106 display(OLED_RESET);

// Servo setup
Servo myServo;

const int touchPin = 2;
const int buzzerPin = 3;
const int servoPin = 9;

// Lockout variables
bool touchDetected = false;
unsigned long touchStartTime = 0;
const unsigned long treatDisplayDuration = 300;  // 300 ms for "Giving Treats"
const unsigned long waitBeforeReady = 2000;      // 2 seconds waiting phase

// OBECK CAT logo image for OLED
const unsigned char cat_bmp[] PROGMEM = {
  0xff, 0xff, 0xff, 0x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