Hi I’m back to share some info about this cool project I did.
I have spent the last few weeks engineering this super cool remote controlled crossbow unit. The basic concept of the project was relatively simple: a crossbow controlled by 3 servo motors– two to position it in a 2 dimensional axis for aim, and another to release a crossbow bolt. I decided to use potentiometers to control the positioning servos, because it seemed most natural. I used a push button to release the trigger servo for the same reason.
All in all, the most time consuming part of the project was not coming up with or designing the unit, but engineering each piece of the crossbow to work in unison with every other. Since there were so many parts moving precisely in a free space, this was quite difficult, especially since the unit needed to work repeatedly.
I decided that the way to allow the crossbow to move in space was to put it in a frame with servos pulling it from the edges of the frame. The vertical movement servo, connected to a small pulley wheel to reduce extraneous movement, pulled the crossbow up, while gravity would allow it to fall if the servo slacked tension. The horizontal servo, however, does not have gravity to counteract it, so I attached to opposite side to a spring that would create tension when pulled against.
Making everything the correct size with just scrap and a lack of proper tools (like a band saw) made it difficult. I spent a lot of time trying to overcome these problems.
One of the most difficult areas to fine tune was the trigger system. It was difficult to create a channel that not only held the crossbow bolt, but also was smooth enough to allow it to uniformly pass through the central hole in the cross bar. I decided to hot glue a plastic straw into a previously created channel in the wooden body of the bow. It took me quite a while to figure out a precise system that would allow the rubber band, which creates the force necessary to propel the bolt, to slide off the servo trigger and go straight into the notched end of the bolt. I used hot glue here like a makeshift 3d printer to make it so that the bolt would always lie in the right place.
In front of the bow I attached a board that a foam and cardboard target could be attached to.
The code was pretty simple for the most part. All I needed to do was connect my two potentiometers to the vertical and horizontal servo motors and make a button press.
#include <Servo.h> const int vertPin = A0; const int horzPin = A1; int trigPin = 3; int trigState = LOW; Servo vertServo; Servo horzServo; Servo trigServo; void setup() { // put your setup code here, to run once: pinMode(trigPin, INPUT); vertServo. attach(9); horzServo. attach(6); trigServo. attach(11); Serial.begin(9600); } void loop() { // put your main code here, to run repeatedly: int vertState = analogRead(vertPin); int horzState = analogRead(horzPin); int trigRead = digitalRead(trigPin); int horzAngle = map(horzState, 0, 1023, 0, 180); int vertAngle = map(vertState, 0, 1023, 0, 180); vertServo.write(vertAngle); horzServo.write(horzAngle); Serial.print("read = "); Serial.println(vertState); // Serial.print(" Vertical = "); // Serial.println(vertAngle); // delay(100); // Serial.println(horzState); // Serial.print("Horizontal = "); // Serial.println(horzPin); if (trigRead == LOW){ trigServo.write (15); } if (trigRead == HIGH) {trigServo.write(40); } }
I was concerned at first that my Arduino output did not have enough power to power all three servos simultaneously, but through experimentation, I found that I didn’t need to connect any external power.
I also found that I had a problem with crossing wires. I fixed this by braiding and twisting the wires connected to the remote controller and cleaning up the wiring of the breadboard in general.
I also had problems with syntax in my code, but once I fixed them, everything ended up coming together beautifully.