What better way to communicate than through fighting? This pair of Arduino-powered robots uses trigger switches to send each other to not-so-nice messages via appendages attached to servo arms. Once one switch is triggered it sends the pair of robots into a fighting match, each hitting the other’s trigger switch until the springs on the bottom of the trashcan robot send it off balance and cause it to miss the lion’s switch.
#include <Servo.h>
Servo my_Servo;
const float escalate = 100;
const int servo_Input = 9;
const int switch_Input = 5;
int onoff = 1;
void setup()
{
my_Servo.attach(servo_Input);
Serial.begin(9600);
}
void loop()
{
onoff = digitalRead(switch_Input);
Serial.print(onoff);
if (onoff == 0) {
my_Servo.write(100);
delay(400);
my_Servo.write(40);
}
else{
my_Servo.write(40);
}
}
Leave a Reply
You must be logged in to post a comment.