Non ci sono prodotti a carrello.
Siamo vicini ad Halloween e come elettronici pensiamo subito a quali progetti realizzare per rendere più giocosa (o spaventosa) questa festa.
Un elemento che non può mancare in qualsiasi evento organizzato per la notte degli spiriti è sicuramente la candela.
Ed ecco quindi un bel progetto che permette di simulare lo sfarfallio di una candela con un microcontrollore.
Per chi non ha dimestichezza con la programmazione può anche optare per un LED effetto fiamma, che simula la candela semplicemente alimentandolo 🙂
Il progetto è basato su un ATTiny85 programmato tramite l’IDE Arduino.
Ecco il codice completo
/* LED Candle Makes an LED pulse randomly to simulate a candles flame. Takes a series of values and randomly generates sets of pulses with varied brightness and frequency within these values. "by A Green for x2Jiggy.com" */ int ledPin = 0; // Pin the LED is connected to int pulseMin = 1; // Minimum number of pulses in each set int pulseMax = 5; // Maximum number of pulses in each set int brightMin = 92; // Baseline LED brightness. Cannot exceed 128. int minDelay = 1000; // Minimum delay between pulse sets (ms) int maxDelay = 5000; // Maximum delay between pulse sets (ms) void setup() { randomSeed (analogRead (3)); // Randomise pinMode(ledPin, OUTPUT); // Sets LED Pin to be an output } void loop() { // For loop sets the number of pulses and repeats these pulses for (int x = random(pulseMin, pulseMax); x > 0; x-- ) { int bright = 224 - random(96); // Sets a random maximum brightness level for this pulse // For loop raises the brightness of the LED from minimum to maximum value for (int y = brightMin; y < bright ; y++) { analogWrite(ledPin, y); delay(3); } // For loop lowers the brightness of the LED from maximum to minimum value for (int y = bright; y > brightMin; y--) { analogWrite(ledPin, y); delay(3); } delay(10); // Adds a delay between pulses to make them more visible } analogWrite(ledPin, brightMin); delay(random(minDelay,maxDelay)); // Adds a delay between pulse sets }