Code to instruct the Nerf Gun to run

Dependencies:   mbed

main.cpp

Committer:
cjedwardz
Date:
2018-02-12
Revision:
0:228a5306ccc7

File content as of revision 0:228a5306ccc7:

//For use with B22 "Excaliber"

#include "mbed.h"
#include "stdio.h"

int bullets = 10;

DigitalOut load(p28);
DigitalOut spin(p27);

DigitalOut spinled(LED1);
DigitalOut loadled(LED2);

int main() 
{   
    while(bullets != 0) 
    {
      //Reset
      load = 0;
      spin = 0;
      
      loadled = 0;
      spinled = 0;
      wait(5.0);
      
      //Start the spinner
      spin = 1;
      spinled = 1;
      wait(2.0);
      
      for(; bullets > 0; bullets--)
      {
      //Load one disc
      load = 1;
      loadled = 1;
      wait(0.5);
      
      load = 0;
      loadled = 0;
      //Turn off the spinner
      wait(1.0);
      }
      
    }
spin = 0;
load = 0;
spinled = 0;
loadled = 0;
}