DC Power Jack Adapter on Amazon
5V 2A DC Power Supply on Amazon
PIR Sensor on Amazon
Neopixel LED strip on Amazon
Arduino Nano on Amazon
20ft of 22/4 Alarm Wire I got from Lowes
5mm Red LED
The code starts by waiting 60 seconds with a flashing informational LED on the face of the unit while the PIR sensor charges up. After that, it flashes the LED quickly for a short time and begins monitoring. When a high signal is detected from the sensor, it begins to flash the LEDs. The loop function continuously executes the flashleds() function, which uses a flag variable (which I called sinflag) that ranges from 0-255 to track it's progress through the pulse. Sinflag is of type "volatile uint8_t" because a volatile variable is stored on the chips RAM rather than the storage which is handy because it can be accessed quicker there, and because you can't have a volatile variable larger than a byte. That variable is then multiplied by the conversionfactor to make sure that a scale from 0-255 corresponds to one sinusoidal wavelength. The output of the wave is then modified so that it too ranges between 0-255, which is the input range for the NeoPixel strip.
If the loop detects that the sensor signal has gone low again signalling the person has walked away, the second if statement will execute the flashleds() function until the sinusoidal pulse has finished. I did this because it bugged me to see the LED strip abruptly change from full brightness to off.
I'm not 100% proud of this code. I think the way that I handle the sinusoidal LED brightness pulsing could be more clever and concise. I also should have used a cosine wave multiplied by negative one so that the sinflag progress variable value that corresponds to the LED being in the off state is 0 instead of an experimentally determined 185. However, the code works well as it is so I won't change it.
If anyone has any suggestions, I'd love to hear them.