// Flickering LED "Candle" // -Uses Pulse-Width Modulation provided by the "analogWrite()" function // // Setup: - Wire an LED from pin 6 through a resistor to ground //--------------------------------------------------------------------- int LEDpin = 6; // Must be one of the PWM pins: 3, 5, 6, 9, 10, or 11 int Brightness; // variable for storing value for analogWrite void setup(){ pinMode(LEDpin, OUTPUT); } void loop(){ Brightness = random(100,255); // random(low range, high range) analogWrite(LEDpin, Brightness); // PWM delay(random(50,280)); // determines how "flickery" } |