This small bug robot freezes in its tracks when it’s about to be “squashed”!
This buggo is trying to escape! Sadly, it can’t go anywhere though coz it’s tethered (to its power source — the Arduino + my computer), but that doesn’t stop him from trying!
Here’s the very simple base design. It mounts two servo motors which rotate in unison. Each servo moves either the front or back legs. To sense a hand getting ready to “squash”, I used a photocell to detect when light decreased.
Here’s my Arduino code.
#include <Servo.h> Servo front; Servo back; void setup() { // put your setup code here, to run once: front.attach(9); back.attach(11); Serial.begin(9600); } void loop() { Serial.println(analogRead(A1)); if (analogRead(A1) > 140) { front.write(35); back.write(35); delay(250); front.write(0); back.write(0); delay(250); } // put your main code here, to run repeatedly: }
Leave a Reply
You must be logged in to post a comment.