Weapon Prototype
Turret Prototype 01 With DC motor as a gun controller With 360 degrees servo as a gun controller YouTube: Video Circuit: Code: (With DC motor as gun controller, this code is under modification) #include <Servo.h> #include <HCSR04.h> Servo base; void rotateBase(); void shoot(); int pir = 5; int trig = 11; int echo = 10; int laser = 13; int gun = 3; int motion = 0, detect = 0, shot = 0, minDistance = 100; long distance = 0; float duration = 0; float oneRotation = 10.87; //DC Motor's one rotation time taken in ms int loaded = 0; void setup() { base.attach(2); pinMode(pir, INPUT); pinMode(laser, OUTPUT); pinMode(trig, OUTPUT); pinMode(echo, INPUT); Serial.begin(9600); base.write(90); digitalWrite(laser, OUTPUT); digitalWrite(gun, OUTPUT); } void loop() { motion = digitalRead(pir); if (motion == 1) { digitalWrite(laser, 1); rotateBase(); } else { digitalWrite(laser, 0); } } void rotateBase() { int basePos = 90; for (basePos =