Boo-Bot: Your (Not So) Handy Specter Deflector

by KvsL in Circuits > Arduino

1051 Views, 13 Favorites, 0 Comments

Boo-Bot: Your (Not So) Handy Specter Deflector

Boo Bot: Your (Not So) Handy Specter Deflector

Is your house haunted? Are you scared of the dark?

Meet Boo-Bot, your personal, cowardly, Arduino-powered ghost-hunting ghost. Boo-Bot reluctantly explores haunted mansions, abandoned buildings, underground tunnels, bedroom closets, and any other dark space. When he detects something supernatural, he panics. He lets out a horrifying shriek, throws up his arms, flashes, and dashes away. With Boo-Bot, you will know when another ghost is near… although he will probably beat you to the door.

// This project was undertaken as part of the Computational Design and Digital Fabrication seminar in the Master's programme Integrative Technologies and Architectural Design Research (ITECH) at the University of Stuttgart.

// Boo-Bot marks our very first venture into the world of electronics projects with Arduino.

// by Bryan Martino, Likhinya KVS, and Muhamad Faiz

Supplies

258a9d97-2851-41d4-b777-7e7e38624841.jpg

Supplies:

  • 1 x Arduino UNO board
  • 1 x breadboard
  • 2 x DC gear motors & wheels
  • 2 x micro servo motors
  • L293D Integrated Circuit
  • 1 x ultrasonic sensor
  • 1 x piezo buzzer
  • 2 x LEDs
  • 3 x 330 ohm resistors
  • 40 x M-M cables
  • 1 x castor wheel
  • 1 x power source (currently DC/AC Adapter)

The DC-motors, wheels and motor driver can be purchased as a kit.

Attached are the 3D printed files for the files: head, body, base, hands.

Logic

Conceptual Research-group 5 (3).jpg
BooBot_Final.jpg

Boo-Bot operates on a simple yet effective system. It navigates forward using the geared motors for propulsion. Obstacle detection is handled by an ultrasonic sensor, triggering a sequence upon detection. This sequence includes halting forward motion, raising arms via servo motor control, activating LED flashes, and sounding a buzzer. To add randomness, Boo-Bot turns either left or right by differential control of the geared motors. All actions, including LED flashes and buzzer sounds, are programmed responses.

Concept Overview:
  • Movement: Boo-Bot moves straight until an obstacle is detected.
  • Detection: Uses an ultrasonic sensor to detect objects within a specified distance.
  • Response: Upon detection, Boo-Bot stops, raises its arms, flashes LEDs, and activates a buzzer.
  • Escape: After the response, Boo-Bot randomly turns left or right and continues moving.


Building the Circuit

Tinkercad Diagram.png
fabrication
26f308f1-b842-4bc1-80ee-0e80d9943852.JPG

Setting up the hardware for Boo-Bot is straightforward. There are two separate loops: one for the geared motors and one for all other components.

  • Arduino Board: Connect the Arduino UNO board to your computer via USB cable.
  • Ultrasonic Sensor: Attach the ultrasonic sensor to pins 7 (trig) and 6 (echo).
  • DC Gear Motors:
  • Connect one motor to pins 8 (forward) and 12 (backward).
  • Connect the other motor to pins 9 (forward) and 11 (backward).
  • Servos:
  • Connect the first servo to pin 5.
  • Connect the second servo to pin 3.
  • LEDs:
  • Attach one LED to pin 13.
  • Attach the other LED to pin 10.
  • Piezo Buzzer: Connect the buzzer to pin 2.
  • L293D IC: Utilize the L293D IC to regulate the DC motors.
  • Breadboard: Arrange the components on a breadboard for convenient connections and adjustments

Boo-Bot's movement behavior entails advancing straight until encountering an obstacle, accompanied by its hands (servo motors) exhibiting nervous movements back and forth. Calibration tasks involve ensuring the proper 90-degree rotation of the servo motors for both clockwise and counterclockwise motions, refining the buzzer volume to achieve the ideal screaming effect, and adjusting the robot's speed to align with its object detection capabilities

Assembly

Assembly and testing
WhatsApp Image 2024-06-08 at 17.04.42.jpeg
c5599269-3fcb-4f59-a3bd-552a57da32c7.JPG
WhatsAppVideo2024-06-10at08.24.14-ezgif.com-crop.gif

Boo-Bot's design is segmented into three components for practical reasons. The head houses permanent fixtures like the ultrasonic sensor, LEDs, and buzzer. The body holds the servo motors in place, with a vertically positioned breadboard and Arduino situated on a shelf. This division facilitates easy assembly and accessibility for calibration. The robot is assembled upside down, starting with the head, followed by the body, and then the base.

Code

The code begins by including the Servo library to enable control of servo motors. Next, it sets up and initializes the pins for input and output operations.

#include <Servo.h>

#define trigPin 7
#define echoPin 6
#define led1 13
#define led2 10
#define buzzer 2

const int forwardPin1 = 8;
const int backwardPin1 = 12;
const int forwardPin2 = 9;
const int backwardPin2 = 11;
const int servoPin1 = 5; // Define the first servo pin
const int servoPin2 = 3; // Define the second servo pin

int sound = 2500;
unsigned long previousMillis = 0;
const long interval = 200; // Interval for blinking (200 ms for faster flashing)
bool ledState = LOW;

const int thresholdDistance = 40; // Distance threshold in cm

Servo servoMotor1; // Create a servo object to control the first servo motor
Servo servoMotor2; // Create a servo object to control the second servo motor


Functions are defined for specific tasks: getDistance() calculates the distance to obstacles, moveStraightWithSwinging() controls forward movement with swinging arm gestures, stopMotors() halts motor activity, turnRandomly() initiates a random turn, and flashLEDsAndSoundBuzzer() triggers visual and auditory alerts upon obstacle detection.

int getDistance() {
  // Trigger the ultrasonic pulse
  digitalWrite(trigPin, LOW);
  delayMicroseconds(1);
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(5);
  digitalWrite(trigPin, LOW);

  // Measure the duration of the echo
  long duration = pulseIn(echoPin, HIGH);

  // Calculate the distance in centimeters
  int distance = (duration / 2) / 29.1;
  return distance;
}
void moveStraightWithSwinging() {
  digitalWrite(forwardPin1, HIGH);
  digitalWrite(backwardPin1, LOW);
  digitalWrite(forwardPin2, HIGH);
  digitalWrite(backwardPin2, LOW);
  // Swing servos back and forth
  for (int pos = 0; pos <= 90; pos += 1) { // Move servos from 0 to 90 degrees
    servoMotor1.write(180 - pos); // Move servoMotor1 counterclockwise
    servoMotor2.write(pos); // Move servoMotor2 clockwise
    delay(2); // Adjust delay for desired swinging speed
  }
  for (int pos = 90; pos >= 0; pos -= 1) { // Move servos from 90 to 0 degrees
    servoMotor1.write(180 - pos); // Move servoMotor1 clockwise
    servoMotor2.write(pos); // Move servoMotor2 counterclockwise
    delay(2); // Adjust delay for desired swinging speed
  }
}

void stopMotors() {
  digitalWrite(forwardPin1, LOW);
  digitalWrite(backwardPin1, LOW);
  digitalWrite(forwardPin2, LOW);
  digitalWrite(backwardPin2, LOW);
}

void turnRandomly() {
  int turnDirection = random(2); // Generate a random number: 0 or 1
  if (turnDirection == 0) {
    // Turn left
    digitalWrite(forwardPin1, LOW);
    digitalWrite(backwardPin1, HIGH);
    digitalWrite(forwardPin2, HIGH);
    digitalWrite(backwardPin2, LOW);
  } else {
    // Turn right
    digitalWrite(forwardPin1, HIGH);
    digitalWrite(backwardPin1, LOW);
    digitalWrite(forwardPin2, LOW);
    digitalWrite(backwardPin2, HIGH);
  }
  delay(500); // Delay for the turn (adjust as needed)
  stopMotors(); // Stop after the turn
}

void flashLEDsAndSoundBuzzer() {
  unsigned long currentMillis = millis();
  unsigned long buzzerDuration = 1000; // Duration of buzzer sound (in milliseconds)
  while (millis() - currentMillis < buzzerDuration) { // Flash LEDs, sound buzzer, and move servos for the specified duration
    if (millis() - previousMillis >= interval) { // Check if it's time to toggle the LED state
      previousMillis = millis();
      ledState = !ledState; // Toggle the LED state
    }
    digitalWrite(led1, ledState);
    digitalWrite(led2, ledState);
    tone(buzzer, sound);

    // Move servo motors 90 degrees
    servoMotor1.write(90); // Rotate servoMotor1 to 90 degrees counterclockwise (upwards)
    servoMotor2.write(90); // Rotate servoMotor2 to 90 degrees clockwise (upwards)
  }
  digitalWrite(led1, HIGH);
  digitalWrite(led2, HIGH);
  noTone(buzzer);

  // Reset servo motors to initial position (0 degrees)
  servoMotor1.write(180);
  servoMotor2.write(0);

  // Stop spinning after the specified duration
  stopMotors();
}


Within the main loop, Boo-Bot continuously moves forward and detects obstacles using getDistance(). When an obstacle is detected, the program calls stopMotors() to halt movement, followed by flashLEDsAndSoundBuzzer() to activate visual and auditory signals. Subsequently, turnRandomly() is invoked to execute a random turn. The effectiveness of Boo-Bot's actions heavily depends on appropriately calibrated delay times to achieve desired functions.

void loop() {
    // Check distance
  int distance = getDistance();
  Serial.print("Distance: ");
  Serial.print(distance);
  Serial.println(" cm");
 
  // If an object is detected within the threshold distance, take actions
  if (distance <= thresholdDistance && distance > 0) {
    stopMotors();
    flashLEDsAndSoundBuzzer();
    delay(200); // Small delay before turning
    turnRandomly();
    delay(200); // Small delay before moving straight again
  }
  // Move straight and swing servos
  moveStraightWithSwinging();

  //delay(1); // Reduced delay between measurements
}

Downloads

Your Boobot Is Ready!

Brave Boo-bot
WhatsApp Image 2024-06-10 at 08.24.09 (1).jpeg
WhatsAppVideo2024-06-03at20.58.36-ezgif.com-video-to-gif-converter.gif
WhatsApp Image 2024-06-10 at 08.24.15.jpeg

Here are some suggestions for optional next steps:

  • You can further adapt the circuit with more sensors and mechanical actuators, try i.e. to have special sensing only for ghosts
  • Have a wifi module to easily send data to the boobot and modify functions
  • Add more actions like spiralling or slowing down in panic, shitting in panic or dancing in happiness.

Do make your very own Boo-Bot this halloween and share it with us!

Have fun!