Project tutorial

Head Swinging Dragonfly © MIT

I made dragonfly. The dragonfly swings head with a gesture sensor and a servo motor.

  • 748 views
  • 2 comments
  • 11 respects

Components and supplies

Apps and online services

About this project

I made dragonfly. The dragonfly swings head with a gesture sensor and a servo motor.

Constitution

Detecting the movement of the finger with the gesture sensor and controlling the rotation direction of the 360 ​​° continuous rotation servo with Arduino.

Create Dragonfly

Head

The head was made with 12 mm long M8 screw. When rotating the head with the servo cut the stick to stop at a fixed angle cut the wire to the appropriate length and solder it to the screw.

Eyes and mouth were made with glittery jewelry seals. I write the mouth with a pen.

The connection between the head and the chest (servo) is made up of a nut. Attach the feathers and nuts attached to the servo with instant adhesive.

Body

Make the servomotor to the dragonfly's chest. Adhered 60 mm long M6 screw as belly.

Screw the nuts created earlier to the servo and bond the feathers of the plaques with the feet of the wire.

Attach a thick wire to the servo so that it catches on the head replacement bar. I solder the thin wire's feet to this thick wire (for stainless steel).

Screw the head into the nut and the dragonfly is completed. Activate the servo and turn it.

360-Degree Continuous Rotation Servo

This servo operates with the Servo library which was originally included in Arduino IDE, but slightly different from normal servo motor.

  • Servo stop with 90 degree input
  • Rotate clockwise with 0 to 89 degrees input. The rotation speed increases farther from 90 degrees.
  • Rotate counterclockwise with input from 91 to 180 degrees. The rotation speed increases farther from 90 degrees.

Arduino Code

Connect servo and gesture sensor to Arduino UNO.

The gesture sensor library uses the following.

https://github.com/Seed-Studio/Gesture_PAJ7620

I looked at the code sample paj7620_9gestures.ino.

The gesture made it recognize the clockwise direction and the counterclockwise direction of the finger.

Arduino's digital 8 pin is connected to GND so that the servo rotates slowly in the counterclockwise direction so that the head screw can be turned into the nut.

Arduino's digital 8 pin open releases the normal operation, and gesture sensor detection starts. Detects the rotation of finger movement and moves according to the servo.

#include <Wire.h>
#include "paj7620.h"
#include <Servo.h>
Servo myservo;  // create servo object to control a servo
void setup() {
 uint8_t error = 0;
 Serial.begin(9600);
 myservo.attach(A0);  // attaches the servo on pin 9 to the servo object
 pinMode(8, INPUT_PULLUP);
 error = paj7620Init();      // initialize Paj7620 registers
 if (error) {
   Serial.print("INIT ERROR,CODE:");
   Serial.println(error);
 }else {
   Serial.println("INIT OK");
 }
 Serial.println("Please input your gestures:\n");
}
void loop() {
 uint8_t data = 0, data1 = 0, error;
 if(digitalRead(8) == LOW){
   myservo.write(90 + 15);
 }else{
   error = paj7620ReadReg(0x43, 1, &data);        // Read Bank_0_Reg_0x43/0x44 for gesture result.
   if (!error) {
     switch (data) {
       case GES_CLOCKWISE_FLAG:
         Serial.println("Clockwise");
         myservo.write(90 - 20);
         delay(800);
         break;
       case GES_COUNT_CLOCKWISE_FLAG:
         Serial.println("anti-clockwise");
         myservo.write(90 + 20);
         delay(800);
         break;
       default:
         myservo.write(90);
         break;
     }
   }
 }
}

Operation

I got a pretty head swing dragonfly!

Comments

Similar projects you might like

Arduino Bluetooth Basic Tutorial

by Mayoogh Girish

  • 455,686 views
  • 42 comments
  • 241 respects

Home Automation Using Raspberry Pi 2 And Windows 10 IoT

Project tutorial by Anurag S. Vasanwala

  • 285,654 views
  • 95 comments
  • 672 respects

Security Access Using RFID Reader

by Aritro Mukherjee

  • 229,701 views
  • 38 comments
  • 239 respects

OpenCat

Project in progress by Team Petoi

  • 199,014 views
  • 155 comments
  • 1,384 respects
Add projectSign up / Login