Saturday, 18 March 2017

Bow and Arrow with Arduino



I'm not sure if anyone has done this before, but I thought it will be cool thing to do with Arduino that you shoot an arrow which can be triggered by light. Yes that's right, it can be triggered by light. That means if someone makes it bigger size and set it between point A and point B, and he puts a laser on the point B then if anything goes between those two point will get direct hit.

Ad

Note: This is just an idea and not intended to harm anything or anyone.


#include <Servo.h>
Servo myservo;
int pos = 0; 
   
    int photocellPin = 0;     // the cell and 10K pulldown are connected to a0
    int photocellReading;     // the analog reading from the sensor divider

    void setup() {
      Serial.begin(9600);  
      myservo.attach(9);
    }
    
    void loop() {
      photocellReading = analogRead(photocellPin);      
      Serial.print("Analog reading = ");
      Serial.println(photocellReading);     // the raw analog reading

     
if (photocellReading <=150){

  for (pos = 0; pos <= 105; pos += 1) { // goes from 0 degrees to 105 degrees   
    myservo.write(pos);              // tell servo to go to position in variable 'pos'
    delay(6);        // waits 6ms for the servo to reach the position
    }
          delay(1000);
  }
  else {
      //
  } 
      delay(100);
    }


Ad

Remember Analog pin 0 is for photo-resistor and digital pin 9 is for servo. You can find the diagram at the end of the video 1:39 video time.

You might have change the photocellReading highlighted in green to match your needs, because light density can be different in efferent condition and location.

Important:
When you make the servo to hold the arrow it, don't make it hold for too long. That's because it tries to go from position 0 to 105 (or what ever you set) but it can't reach to the 105 position because of the arrow handle, and it still keeps trying to reach, and that makes it go hotter and hotter. You might burn it if you keep it too long.
Ad


No comments:

Post a Comment