Hi all, Here's the code for the project: #include Servo servos[12]; unsigned long lastFastMoveTime = 0; bool fastMoveActive = false; void centerServos() { for (int i = 0; i < 12; i++) { servos[i].write(90); // Center each servo to 90 degrees } delay(3000); // Wait for 1 second after centering servos } void setup() { for (int i = 0; i < 12; i++) { servos[i].attach(i + 2); // Attach each servo to a pin (pins 2 to 13) }
randomSeed(analogRead(0)); // Seed the random number generator with an analog pin's value
centerServos(); // Center the servos upon startup } void loop() { unsigned long currentTime = millis();
// Check if it's time to activate fast servo movements if (!fastMoveActive && (currentTime - lastFastMoveTime >= random(60000, 120000))) { delay(3000); // Delay for 3 seconds before starting fast movements
// Move all servos fast and randomly for 8 seconds unsigned long fastMoveEndTime = currentTime + 8000; while (millis() < fastMoveEndTime) { for (int i = 0; i < 12; i++) { servos[i].write(random(0, 180)); } }
fastMoveActive = false; }
// If fastMoveActive is false, continue with normal random movements if (!fastMoveActive) { int randomDelay = random(300, 1200); // Generate a random delay between movements (faster) delay(randomDelay); // Wait for a random amount of time before the next movement
// Move each servo to a random position within its range for (int i = 0; i < 12; i++) { servos[i].write(random(0, 180)); } } }
So interesting project it is! Wondering if any custom PCBs and 3D printing services may help for upcoming projects? Would love to sponsor!! (PCBWay zoey)
Hi all,
Here's the code for the project:
#include
Servo servos[12];
unsigned long lastFastMoveTime = 0;
bool fastMoveActive = false;
void centerServos() {
for (int i = 0; i < 12; i++) {
servos[i].write(90); // Center each servo to 90 degrees
}
delay(3000); // Wait for 1 second after centering servos
}
void setup() {
for (int i = 0; i < 12; i++) {
servos[i].attach(i + 2); // Attach each servo to a pin (pins 2 to 13)
}
randomSeed(analogRead(0)); // Seed the random number generator with an analog pin's value
centerServos(); // Center the servos upon startup
}
void loop() {
unsigned long currentTime = millis();
// Check if it's time to activate fast servo movements
if (!fastMoveActive && (currentTime - lastFastMoveTime >= random(60000, 120000))) {
delay(3000); // Delay for 3 seconds before starting fast movements
fastMoveActive = true;
lastFastMoveTime = currentTime;
// Move all servos fast and randomly for 8 seconds
unsigned long fastMoveEndTime = currentTime + 8000;
while (millis() < fastMoveEndTime) {
for (int i = 0; i < 12; i++) {
servos[i].write(random(0, 180));
}
}
fastMoveActive = false;
}
// If fastMoveActive is false, continue with normal random movements
if (!fastMoveActive) {
int randomDelay = random(300, 1200); // Generate a random delay between movements (faster)
delay(randomDelay); // Wait for a random amount of time before the next movement
// Move each servo to a random position within its range
for (int i = 0; i < 12; i++) {
servos[i].write(random(0, 180));
}
}
}
So interesting project it is! Wondering if any custom PCBs and 3D printing services may help for upcoming projects? Would love to sponsor!! (PCBWay zoey)
Really nice work ❤
Thanks! ☺️
1st 😁😁
No, I was first 😆
Really nice , worth tot look
Very special
Promo*SM