Tupperware Turret Airsoft Gun

Program Download:

Main C File
Turret_Software.c

The Software
           There are three main portions of code that we are concerned with:
    -Fire Control
    -Servo Control
    -IR Command Decoding

Since I've already covered a lot of the software concepts at play in the code for this project in the Servo Motor Control and Infrared IR Receiver tutorials, the focus here will be on how the command/control structure is built to tell each device what to do from specific input commands.

Command Switch Statement

------------« Begin Code »------------
switch(active_command) 
    { 
    .. 
    ... 
    .. 
       //Select 
    case 0x3C6 : 
          active_command=0; 
          servo_0 = 0xFA23; 
          servo_0_direction = 0x00; 
          servo_1_direction = 0x00; 
          break; 
       //Left 
    case 0x7BE : 
          active_command=0; 
          servo_0 = 0xFA00; 
          break; 
       //Right 
    case 0x3CE : 
          active_command=0; 
          servo_0 = 0xFA33; 
          break; 
       //Up 
    case 0x3D3 : 
          active_command=0; 
          servo_1_direction = 0xF0; 
          //PORTD = 0x00; 
          break; 
       //Down 
    case 0x3D7 : 
          active_command=0; 
          servo_1_direction = 0xE0; 
          break; 
.. 
... 
.. 
       //Red 
    case 0x1D9 : 
          active_command=0; 
          PORTD = 0x00; 
          break; 
       //Green 
    case 0x3BC : 
          active_command=0; 
          PORTD = 0x01; 
          break; 
} 
------------« End Code »------------

           Each command above is responsible for performing a specific task. Select, for example, clears the servos values, while the Red and Green buttons are responsible for flipping a single bit to trigger fire control. Skim through the switch statement above and you get a pretty solid idea of how things are structured at a high level. Download the source code above to see how everything is done.




;