Introduction: Laser Fighting Robot
Hello, Everyone. This is a series of courses, I will share how to use cartons and arduino to make something interesting,today,I'll share with you a laser fighting robot, and I'll show you how to make a robot. By the way,I am very poor standard of English.Hope you will understand me.
Game rules, through the production of two or more battle robots, remote control of the laser head movement, when the laser light to the other side of the photosensitive resistor on the carton, the description was hit, the robot stopped working
Step 1: You Need to Prepare These Materials
Step 2: Circuit Diagram
Step 3: Assembly
In this step, I will show how to build a laser fighting robot. Servo base was use of 3d printing, of course,you can also buy in the Amazon or other web site
Step 4: Code
#include<Servo.h>
Servo servo_8;
Servo servo_9;
void setup()
{
Serial.begin(9600);
pinMode(13, OUTPUT);
pinMode(2, OUTPUT);
servo_8.attach(8);
servo_9.attach(9);
}
void loop()
{
Serial.println(analogRead(A2));
digitalWrite(13,HIGH);
if (analogRead(A2) > 150) {
digitalWrite(13,LOW);
tone(2,131);
delay(500);
noTone(2);
delay(500);
while(true);
} else {
servo_8.write((map(analogRead(A1), 1, 1023, 1, 180)));
delay(50);
servo_9.write((map(analogRead(A0), 1, 1023, 45, 135)));
delay(50);
}
}
Step 5: GameRules
You need to make two laser fighting robots.Use the joystick to control the movement of the laser head. When the laser irradiates the other side of the photosensitive resistor on the carton of the opposite party,The robot stopped working.