Finger Chomper

by miasclin in Circuits > Arduino

47 Views, 0 Favorites, 0 Comments

Finger Chomper

DSC_0298.JPG

This Arduino-based interactive crocodile device is an engaging and fascinating maker project that combines electronic components with creative design. The core functionality of the device simulates a mechanical crocodile that quickly "bites" when it detects a hand approaching, accompanied by the illumination of colorful LED lights in its eyes, mimicking the crocodile’s hunting behavior. This project not only enhances interactivity but also demonstrates the collaborative use of sensors, servo motors, and LED lights.

The main components of the device include an Arduino as the control board, an infrared sensor (or ultrasonic sensor) to detect the proximity of a hand, a servo motor to control the crocodile's jaw movements, and two red LED lights to simulate glowing crocodile eyes. When the sensor detects a hand nearby, the Arduino controls the servo motor to open and quickly close the crocodile's mouth, completing a "biting" action. Following this, the LED lights illuminate for about one second, further enhancing the effect and mimicking the crocodile's warning stance.

The design of this device is highly creative and practical. In terms of hardware, materials like cardboard or plastic can be used to create the crocodile's shell, with the servo motor embedded within the jaw structure to enable rotational movements for opening and closing. The infrared sensor has high sensitivity, effectively detecting hand movement and triggering the Arduino to execute commands. On the software side, the simple code facilitates diverse interactive effects and allows for future extensions, such as adding sound simulation or more complex behavioral patterns.

This project is not only a fun electronic device but also an excellent tool for learning Arduino technology. It helps makers improve their skills in electronics and programming while inspiring more creative projects.










Downloads

Supplies

  1. Arduino x 1
  2. Servo motor (SG90) x 1
  3. Infrared sensor (or ultrasonic distance sensor) x 1
  4. LED lights (Rainbow) x 2
  5. Breadboard and jumper wires (several)
  6. Crocodile model or self-made cardboard structure

croc2.jpg
20241124_140653.JPG
20241124_142113.JPG
20241124_154717.JPG
20241124_154723.JPG
DSC_0298.JPG

Step 1: Prepare the Crocodile Structure

  1. Create the crocodile body using cardboard, plastic, or a pre-made crocodile model.
  2. Design a movable jaw by attaching the upper jaw to the servo motor horn. Ensure the servo motor is securely installed within the structure.
  3. Place the LED lights in the crocodile's eye sockets, and organize the wires neatly to avoid tangling.

Step 2: Connect the Electronic Components

Connect the Servo Motor:

  1. Attach the signal wire of the SG90 servo motor to pin D9 on the Arduino.
  2. Connect the VCC wire to the 5V pin on the Arduino and the GND wire to the GND pin.

Install the Infrared (or Ultrasonic) Sensor:

  1. Mount the sensor at the front of the crocodile's head.
  2. Connect the sensor’s signal pin to pin D2 on the Arduino.
  3. Connect the VCC and GND pins to the 5V and GND pins on the Arduino, respectively.

Connect the LED Eyes:

  1. Attach the positive leg of one LED to pin D3 on the Arduino and the other LED to pin D4.
  2. Connect the negative legs of the LEDs to GND through resistors to limit current.
  3. Use a breadboard and jumper wires to neatly organize and secure all connections.

Step 3: Upload the Code

  1. Write or load the provided Arduino code to control the servo motor, sensor, and LEDs.
  2. Connect the Arduino to your computer using a USB cable.
  3. Open the Arduino IDE, select the correct port, and upload the code.

Step 4: Power and Test the Device

  1. After uploading the code, power the Arduino using your computer or an external 5V power supply.
  2. Test the crocodile by moving your hand in front of the sensor. The servo motor should drive the mouth to "bite," and the LEDs should light up.

Step 5: Adjust and Finalize

  1. If needed, adjust the range of the jaw's movement by modifying the servo motor settings in the code.
  2. Secure all components inside the crocodile structure to prevent shifting during operation.
  3. Add decorations to the crocodile for a more attractive appearance if desired.

Your interactive crocodile is now complete! Enjoy testing and showcasing this fun project! 🐊







#include <Servo.h> // Include the servo motor library

Servo myServo; // Create servo object

int servoPin = 7; // Define the servo signal pin

#include <Adafruit_NeoPixel.h>

// Set up the parameters for the LED strip

#define LED_PIN 6  // The signal pin of the LED strip

#define NUM_LEDS 30 // The number of LEDs on the strip

#define SENSOR_PIN 4 // The digital output of the sensor connected to pin 2 on the Arduino

Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUM_LEDS, LED_PIN, NEO_GRB + NEO_KHZ800);

void setup() {

  strip.begin();  // Initialize the LED strip

  strip.show();   // Ensure all LEDs are off

  pinMode(SENSOR_PIN, INPUT); // Set the sensor pin as input

  Serial.begin(9600);

  myServo.attach(servoPin); // Attach the servo object to the specified pin

}

void loop() {

  int sensorState = digitalRead(SENSOR_PIN); // Read the sensor state

  myServo.write(20);

  if (sensorState == LOW) { // LOW usually means obstacle detected

    Serial.println("Obstacle detected!");

    myServo.write(150);

    rainbowCycle(0); // Show rainbow effect, 10 is the speed parameter

    delay(500); // Stay for 1

    turnOffAllLEDs();

    myServo.write(20);

    delay(2000); // Stay for 1 second

  } else {

    Serial.println("No obstacle.");

  }

}

// Custom function: Turn off all LEDs

void turnOffAllLEDs() {

  for (int i = 0; i < strip.numPixels(); i++) {

    strip.setPixelColor(i, 0); // Set RGB to 0 (black)

  }

  strip.show(); // Send data to the LED strip

}

// Rainbow effect function

void rainbowCycle(uint8_t wait) {

  uint16_t i, j;

  for (j = 0; j < 256 * 5; j++) { // 256 colors, each LED cycles 5 times

    for (i = 0; i < strip.numPixels(); i++) {

      strip.setPixelColor(i, Wheel(((i * 256 / strip.numPixels()) + j) & 255));

    }

    strip.show();

    delay(wait);

  }

}

// Color conversion function

uint32_t Wheel(byte WheelPos) {

  WheelPos = 255 - WheelPos;

  if (WheelPos < 85) {

    return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);

  }

  if (WheelPos < 170) {

    WheelPos -= 85;

    return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);

  }

  WheelPos -= 170;

  return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);

}