const int buttonPin = 5; // the number of the pushbutton pin const int laserPin = 7; // the number of the LED or mosfet/laser pin //const int recoilpin = 12; // the number of the recoil MOSFET pin //const int audiopin = 11; // the number of the Audio pin // variables will change: int buttonState = 0; // variable for reading the pushbutton status int buttonStateLast = 0; // variable for recording last button state void setup() { pinMode(laserPin, OUTPUT); // initialize the laser pin as an output: //pinMode(recoilpin, OUTPUT); //initialize the recoil pin as an output: //pinMode(audiopin, OUTPUT); // initialise the audio pin as an output: pinMode(buttonPin, INPUT); // initialize the pushbutton pin as an input: } void loop() { // read the state of the pushbutton value: buttonState = digitalRead(buttonPin); // Determine when button pressed . . . if (buttonState == HIGH and buttonState != buttonStateLast) { // turn Laser, recoil and audio on: digitalWrite(laserPin, HIGH); // digitalWrite(recoilpin, HIGH); // digitalWrite(audiopin, HIGH); delay(100); // wait for a tenth of a second digitalWrite(laserPin, LOW); // digitalWrite(recoilpin, LOW); // digitalWrite(audiopin, LOW); } buttonStateLast = buttonState; }