In this setup we ended up using an NPN transistor. This is a helpful site to learn about the differences in transistors and how they work: Click

int led=3;//base
int button=4;
int vcc=5;
int ground=13;

void onoff(void);
void setup(){
  pinMode(led, OUTPUT);
  pinMode(button, INPUT);
 pinMode(vcc, OUTPUT);
  pinMode(ground, OUTPUT);
  
  digitalWrite(led, LOW);
  digitalWrite(ground, LOW);
  digitalWrite(vcc, HIGH);
  
 Serial.begin(9600);
}
void loop(){
  if(digitalRead(button)==1){
    onoff();
    Serial.println("I am shooting--PEW");
  }
}
void onoff(void){
  for(int i=0; i<3; i++){
    digitalWrite(led, HIGH);
    delay(100);
    digitalWrite(led, LOW);
    delay(100);
  }
  delay(500);//delay between shots
  
}

Here is the promised circuits diagram:

 
classes/designandproto/me155a_groups/shooting_in_an_interesting_way.txt · Last modified: 2013/03/25 19:46 by nmitchell
 
Except where otherwise noted, content on this wiki is licensed under the following license:CC Attribution-Noncommercial-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki