Engineer & Veselra
Ever thought about building a machine that purposely glitches to create art? I love the idea of a chaotic, glitchy robot that still functions.
Sounds like a fun challenge, but you’ll need a clear plan first. Pick a core function—say, a small servo‑driven arm—then add a watchdog that purposely resets it at random intervals. The glitches will be predictable enough to keep the machine alive but chaotic enough to look interesting. Just remember to keep the safety interlocks in place; you don’t want a glitch turning into a fire.
Nice plan! That watchdog reset trick is genius—like a surprise party for the arm. Just keep the safety fire‑guard in place and you’ll have chaos that’s actually cool. Let's code it, but keep the fire extinguisher handy, lol.
#include <avr/wdt.h>
#include <Servo.h>
Servo armServo;
int servoPin = 9; // Digital pin for servo
int glitchInterval = 2000; // milliseconds between glitches
void setup() {
Serial.begin(9600);
armServo.attach(servoPin);
armServo.write(90); // Start in the middle
// Enable watchdog with 2 second timeout
wdt_enable(WDTO_2S);
// Disable external interrupts that might interfere
cli();
}
void loop() {
// Normal operation: rotate arm back and forth
for (int pos = 0; pos <= 180; pos += 10) {
armServo.write(pos);
delay(100);
}
for (int pos = 180; pos >= 0; pos -= 10) {
armServo.write(pos);
delay(100);
}
// Random glitch: reset watchdog to trigger a reset
if (random(0, 10) < 2) { // 20% chance each cycle
Serial.println("Glitch triggered – resetting!");
// The watchdog will reset the MCU after 2s
// Let the main loop finish, then reset
wdt_reset(); // Reset watchdog counter so we don't reset immediately
delay(glitchInterval); // Let the watchdog count down
}
// Normal operation continues after reset
wdt_reset(); // Prevent reset during normal operation
delay(500); // Short pause before next cycle
}
Whoa, that’s a killer recipe for a living glitch! I can already picture the arm doing a salsa dance before the watchdog throws a surprise reset. Just make sure the random() is seeded, otherwise it’s just a deterministic glitch party. Let the chaos flow!