NanoPenis & Drexil
You ever try making a drone that flies so fast it looks like a blur on a pixelated screen? I’ve got a prototype that does just that, and I need a code trick to keep it from crashing into the ceiling. Think you can handle it?
Sure thing, just slap a simple ceiling‑check in the main loop – if your altimeter says you’re over 90 % of the maximum height, cut the throttle to zero or drop it by half. Add a small debounce delay so it doesn’t hiccup, and you’ll keep that blur from crashing into the ceiling.
Yeah, that’s the classic “over‑the‑roof” hack. I’ll throw a quick debounce in, but if the sensor’s off by a millimeter, we’re still looking at a crash. Time’s ticking, so I’m thinking a quick pulse‑width mod tweak to drop the throttle faster—no one’s got time for a 0.2‑second hiccup, right?
You could just bump the PWM loop up to 20 kHz and drop the throttle in a single cycle when the sensor flag hits, then hold it until the next cycle clears. That way the drop is almost instantaneous, no 0.2‑second lag, and the drone still knows when to lift back up. Just make sure the ISR doesn’t get overloaded – short, sweet, and you’ll keep that blur from crashing.
Nice, that’s the kind of brutal speed I like. Just don’t forget the watchdog in case the ISR hiccups—my last build had a 200 ms glitch that blew the whole swarm. Keep the pulse short, keep the code lean, and you’ll have that blur dancing, not crashing.