Introduction: Angry Birds Sentry Gun


The best way to learn C programming is going hands-on with it. And even better if you can control a angry bird launcher tower !

For my programming class, i build an arduino controlled sentry gun.

The objective was develop a software in C language to control the sentry gun through USB. The sentry gun is direct controlled by an arduino mega. The students send commands to the arduino using a custom board connected to the computer USB port. The software was developed for a PC running Linux.

Besides that, the interface must be like a game, showing the score of the user (how many times they hit the pigs !). To count the "pig hits", there is a sonar attached to the arduino to measure the distance to the target setup. If the distance change the students know that the target collapsed.

The Hardware

The hardware is divided in two parts: the sentry gun and the hit detection tower.

Sentry Gun

The gun use two servo motors to move up/down and left/right. Four external digital signals control the movement, with fixed velocity.

To launch the bird, the main barrel uses rubber bands and a custom trigger. The trigger is released with a micro servo (9g). The process to arm the gun is manual, pulling the launch mechanism until its locked in place.

Detection Tower

The target is a Angry Birds toy kit. To detect that the target was hit by the bird, a tower with a sonar measure the distance to the target. If that distance is larger than a predefined value, the system knows that the target was shot down.

To adjust for different target setups, the sonar can be repositioned using velcro glued in the tower.

Source Code

In the attachments you can download the source code for the Arduino Mega.