• Tag Archives flickering led
  • Arduino Flickering Code

    A number of people have asked me for the code for the Flickering LED for my Steampunk Tesla Cane.

    It’s a modified version of the standard “Fade” Arduino example code. The original code I borrowed appears to have disappeared, but this instructable (not mine) has some “flickering” sample code: that is very similar:

    Flickering Arduino Instructable

    Roughly, you make an array of values (the flicker[] below) and cycle through them. Some versions are far more complex, and generate a pseudo-random number for each step instead of a static set of values.

    int ledPin = 10;
    byte flicker[] = {180, 30, 89, 23, 255, 200, 90, 150, 60, 230, 180, 45, 90};

    void setup()
    pinMode(ledPin, OUTPUT);

    void loop()
    for(int i=0; i,7; i++)
    analogWrite(ledPin, flicker[i]);