Polka Dot Monster

by Megan Wu吳 in Craft > Cardboard

517 Views, 1 Favorites, 0 Comments

Polka Dot Monster

IMG-6420 (1).JPG

This project’s called the polka dot monster which opens and closes its mouth automatically. The structure of this machine comes from the idea of trash cans, once the sensor sensed things within 40cm, it’ll make the servo arm that is connected to the micro servo to turn. The turning arm could then hit the cabin cover, making the box to open. However, I turned it into a game, which if the player could throw balls in when the box opens(the monster’s mouth). Then they win.

Supplies

  1. Arduino UNO
  2. Micro servo Sg90
  3. Servo arms
  4. Ultrasound sensor
  5. cardboard box
  6. Decorations

Connect the Circuit and the Servo Arm

arduino 電路圖.jpg
IMG-6429 (1).jpg
servo and servo arm.jpg
  • vcc goes to 5v
  • gnd goes to gnd
  • trig of sensor goes to pin 12
  • echo of sensor goes to pin 13

Add in the Program

arduino trashcan 1.jpg
arduino trashcan 2.jpg
arduino trashcan 3.jpg
<p>#include    //servo library<br>Servo servo;     
int trigPin = 5;    
int echoPin = 6;   
int servoPin = 7;
int led= 10;
long duration, dist, average;   
long aver[3];   //array for average</p><p>void setup() {       <br>    Serial.begin(9600);
    servo.attach(servoPin);  
    pinMode(trigPin, OUTPUT);  
    pinMode(echoPin, INPUT);  
    servo.write(0);         //close cap on power on
    delay(500);
    servo.detach(); 
}</p><p>void measure() {  <br> digitalWrite(10,HIGH);
digitalWrite(trigPin, LOW);
delayMicroseconds(5);
digitalWrite(trigPin, HIGH);
delayMicroseconds(15);
digitalWrite(trigPin, LOW);
pinMode(echoPin, INPUT);
duration = pulseIn(echoPin, HIGH);
dist = (duration/2) / 29.1;    //obtain distance
}</p><p>void loop() { <br>  for (int i=0;i<=2;i++) {   //average distance
    measure();               
   aver[i]=dist;            
    delay(10);              //delay between measurements
  }
 dist=(aver[0]+aver[1]+aver[2])/3;</p><p>if ( dist<10 ) {<br>//Change distance as per your need
 servo.attach(servoPin);
  delay(1);
  servo.write(0);  
  delay(5  00);       
//  servo.write(100);    
//  delay(30);
 servo.detach();      
}
Serial.print(dist);
}</p>

Testing

IMG 6421
  1. Check if the servo motor can push the cabin cover successfully without getting stuck
  2. Check if there's something not stable inside the box
  3. Check if it can work stably

Citations:

https://www.instructables.com/id/TRASH-BOT-Arduino...

https://www.instructables.com/id/Matching-3D-print...

https://www.instructables.com/id/Smart-Home-Arduin...