Halloween Crazy Head - Pau Tubau & Alan Wückert
by alanloza000 in Circuits > Arduino
122 Views, 1 Favorites, 0 Comments
Halloween Crazy Head - Pau Tubau & Alan Wückert

The objective is to design and program in arudino, a project with a halloween theme, in which at least has to have a ulteasonic sensor, leds and servomotors. In our case it has been decided to make a terrifying head that moves by itself while illuminating and moving the eyes.
Supplies

Electronic supplies
- x1 Arduino Uno r3
- x2 Red led
- x2 Dcmotor
- x1 Ultrasonic sensor
- x2 Servomotors
- x2 batterys 9V
- x2 360 ohms resistors
- x1 L298H (driber dcmotors)
- x1 DIY PCB
- x22 wires
Other supplies
- x2 wheels
- x1 terrorific mask
- x1 hat
Circuit

Circuit in Thinkercad.
Function 01 - Turno on Eyes

void routine01(unsigned long t){
unsigned long d = t - start_time;
if(step == 0){
digitalWrite(12, LOW);
digitalWrite(13, LOW);
start_time = t;
step = 1;
}
else if (d < 300 && step == 1){
digitalWrite(12, HIGH);
digitalWrite(13, HIGH);
start_time = t;
}
else if (d >= 300 && step == 1){
digitalWrite(12, LOW);
digitalWrite(13, LOW);
start_time = t;
}
step = 0 ;
}
Function 02 - Roll Eyes


void routine02(unsigned long t){
unsigned long d = t - start_time;
if(step == 0){
eyeleft.attach(A0); //attaches the servo on pin A5 to the servo object
eyeright.attach(A1); //attaches the servo on pin A4 to the servo object
int pos_1 = 0;
int pos_2 = 180;
while (pos_1 <= 180 && pos_2 >= 0) {
eyeleft.write(pos_1); // tell servo to go to position in variable 'pos'
eyeright.write(pos_2); // tell servo to go to position in variable 'pos'
delay(25); // waits 15 ms for the servo to reach the position
pos_1 += 2; // plus 2 degrees
pos_2 -= 2; // subtract 2 degrees
start_time = t; // start_time now is the time it took to do the routine
}
step = 0;
}
Function 03 - Roll 360º Head With Wheels

void routine03(unsigned long t){
unsigned long d = t -start_time;
digitalWrite(ENA, HIGH);
digitalWrite(IN1, LOW);
digitalWrite(IN2, HIGH);
digitalWrite(ENB, HIGH);
digitalWrite(IN3, HIGH);
digitalWrite(IN4, LOW);
start_time = t;
}