Hello there,
I Have 4 arduino UNO's and 1 nano availiable but I am trying to put most of my project in one and I've never really worked with arduinos or code in general before
I have finally had the will power to begin this project of basically Freddy from fnaf and I got working Eyes using 6 Servos and a mouth using one servo (Also there is 1 button on the nose which doesn't properly work with my current code)
basically I want it to look as human like as possible with blinking and looking around after I did that I added the jaw and the nose button but that's where it went down hill. because you cant multitask with one singular arduino UNO (to my knowledge) it blinks looks around and repeat with an occasional "jumpscare" by which he opens his mouth and widens his eyes
here is the current code sorry by the way:
#include <Servo.h>
Servo servo_2;
Servo servo_4;
Servo servo_7;
Servo servo_8;
Servo servo_12;
Servo servo_13;
Servo servo_10;
double math_random_int(int a,int b) {
if (a > b) {
int c = a;
a = b;
b = c;
}
return (double)random(a,b+1);
}
int fnc_dynamic_digitalRead(int _pin){
pinMode(_pin,INPUT);
return digitalRead(_pin);
}
void setup()
{
servo_2.attach(2);
servo_4.attach(4);
servo_7.attach(7);
servo_8.attach(8);
servo_12.attach(12);
servo_13.attach(13);
servo_10.attach(10);
pinMode(6, OUTPUT);
randomSeed(analogRead(0));
servo_2.write(90);
delay(1);
servo_4.write(90);
delay(1);
servo_7.write(35);
delay(1);
servo_8.write(155);
delay(1);
servo_12.write(40);
delay(1);
servo_13.write(155);
delay(1);
servo_10.write(0);
delay(1);
digitalWrite(6, LOW);
}
void loop()
{
for (int count = 0; count < 1000000; count++) {
delay((math_random_int(2000, 10000)));
servo_2.write(90);
delay(1);
servo_4.write(90);
delay(1);
delay((math_random_int(2000, 10000)));
for (int count = 0; count < math_random_int(0, 4); count++) {
delay((math_random_int(400, 1500)));
servo_7.write(100);
delay(1);
servo_8.write(105);
delay(1);
servo_12.write(90);
delay(1);
servo_13.write(80);
delay(1);
delay((math_random_int(300, 400)));
servo_7.write(35);
delay(1);
servo_8.write(155);
delay(1);
servo_12.write(40);
delay(1);
servo_13.write(155);
delay(1);
delay(1000);
}
if ((math_random_int(1, 20) >= 12)) {
servo_10.write((math_random_int(0, 80)));
delay(1);
delay(1000);
}
delay((math_random_int(2000, 10000)));
for (int count = 0; count < math_random_int(1, 5); count++) {
delay((math_random_int(200, 3000)));
servo_2.write((math_random_int(40, 120)));
servo_4.write((math_random_int(40, 120)));
delay(1000);
}
}
if ((math_random_int(1, 20) >= 19)) {
servo_8.write(170);
delay(1);
servo_12.write(25);
delay(1);
servo_10.write(0);
delay(1);
delay(7000);
servo_8.write(155);
delay(1);
servo_12.write(40);
delay(1);
servo_10.write(180);
delay(1);
}
if ((fnc_dynamic_digitalRead(6) == true)) {
servo_7.write(100);
delay(1);
servo_8.write(105);
delay(1);
servo_12.write(90);
delay(1);
servo_13.write(80);
delay(1);
servo_10.write(180);
delay(1);
delay(5000);
}
}
Current problems i have:
Blinking and then looking around isn't exactly my imagination of this project
button not working (at least with that code)
I wanna add at least 2 or 3 more servos but i am willing to put them on a separate Arduino because head and torso rotation should definitely be separate from the Eyes n stuff
if you have any suggestions tips or solutions then please don't be shy because i really need help and if i should just use more arduinos for different parts is there any way to link them together without purchasing 5 different units
thanks in advance and sorry again for the code
ps. all of the pins correlate to:
Servos on 2 and 4 - Eye movement left right up down
Servos on 7,8,12 and 13 - Each Eyelid upper left right lower left right
Servo on 10 - Jaw movement
Button on 6 - on the nose (Should make an iconic boop sound in the future)