Polka Dot Monster
.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
- Arduino UNO
- Micro servo Sg90
- Servo arms
- Ultrasound sensor
- cardboard box
- Decorations
Connect the Circuit and the 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



<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

- Check if the servo motor can push the cabin cover successfully without getting stuck
- Check if there's something not stable inside the box
- Check if it can work stably
Citations:
https://www.instructables.com/id/TRASH-BOT-Arduino...