Arduino-controlled Nerf Pulse Rifle

This is my first project using the Arduino. It’s been a lot of fun and I wanted to share my experience.

The rifle is part of a “Space Marine” Halloween costume. To avoid being shot by the police, I figured some pulsating LEDs down the inside of the barrel would look pretty cool and hopefully make it safe… These are just some pictures and links of the little project:

This is a ‘making of’ video:

And this is a short ‘finished project’ video:

12PulseRifle.jpg

Also, this is the sketch code that makes the in and out fade:

int value;
int ledpin = 3; // light connected to digital pin 3
int ledpin2 = 6; //light connected to digital pin 6
int ledpin3 = 9; // light connected to digital pin 9
int ledpin4 = 11; // light connected to digital pin 11
long x=1;
void setup()
{
// nothing for setup
}
void loop()
{
value = 128+127sin(x0.0174532925); //Degrees to radians
analogWrite(ledpin, value); // sets the value (range from 0 to 255)
analogWrite(ledpin2, value); // sets the value (range from 0 to 255)
analogWrite(ledpin3, value); // sets the value (range from 0 to 255)
analogWrite(ledpin4, value); // sets the value (range from 0 to 255)
if (x==360)
{
x==0;
}
delay(100);
x += 1;
}