Automated color targeting catapult.

Description:

This project is a basic catapult toy that shoots at red object. As it scans horizontally it takes pictures and scans for the color red and shoots a projectile towards the object.

The operation is as follows: The catapult is loaded and then turned on. The camera takes a picture and system converts JPEG image to BMP file. The program then searches through the pixel array to find red pixels. When the number of red pixels exceeds the threshold the program gives the "Fire!" command. This releases the latch and allows the spring to accelerate the arm and therefore propel the projectile towards the target. After the catapult is fired, the DC motor winds down the arm, the latching servo latches the arm, and finally the DC motor releases the tension and fully slacks the line. Once this process is finished, the system starts back over searching at the initial (far left) panning position and continues searching.

Note: The user must reload the ammunition or make a system to automatically reload.

Components:

  • 1 LPC1768 mbed
  • 1 LSY201 JPEG camera.
  • 1 Large Hitec servo to pan the catapult base
  • 1 small Hitec servo to latch and fire catapult
  • 1 DC motor to pull down catapult arm
  • 1 H-bridge to control DC motor
  • Voltage Source : 6 V battery pack
  • Catapult arm and spring
  • 1000uf capacitor.

/media/uploads/pharp6/20140429_171932.jpg /media/uploads/pharp6/20140430_103342.jpg

Code references:

For LS Y201 go here: http://mbed.org/cookbook/Camera_LS_Y201

For servo go here: https://mbed.org/cookbook/Servo

For DC motor go here: https://mbed.org/cookbook/Motor

Import programColor_Targeting_Catapult

Any changes are to allow conversion to BMP

Code for main() function

Main code for Catapult control

int main()
{
    int sum = 0;
    camera_init();
 
    int fired = 0;
 
    Latch();
 
 
    while(1){
        fired = 0;
        sum = 0;
        for(float i = 0.1; i< .9; i+= .10){ //Scans left to right
            Panning = i;
            wait(.01);
            
            take_picture();
            convert_to_bmp();   
            sum = read_picture(); // Returns total number of red pixels
            printf("sum that matters: %i\r\n", sum);
            if (sum > 400){ // If the number of red pixels is above the threshold: Fire and reload
                i-=.1;
                Panning = i;
                Fire();
                dcreload();
                Latch();
                dcrelease();
                fired = 1;
                break;
            }   
        }
        
        
        
        for(float i = 0.9; i> .1; i-= .10){ //Scans right to left
            if (fired == 1)
                break;
                
            Panning = i;
            wait(.01);
            
            take_picture();
            convert_to_bmp();   
            sum = read_picture();   // Returns total number of red pixels
            
            if (sum > 400){ // If the number of red pixels is above the threshold: Fire and reload
                i+=.1;
                Panning = i;
                Fire();
                dcreload();
                Latch();
                dcrelease();
                break;
            }   
        }       
               
    }
 
}
 
 


1 comment on Automated color targeting catapult. :

» Show archived comment by simon
16 Apr 2014

looking forward to when you got sumin

Please log in to post comments.