From 42269ce786872beede336b064685b62e208bbc61 Mon Sep 17 00:00:00 2001 From: Petr Koklev Date: Thu, 5 Jun 2025 10:33:15 +0300 Subject: [PATCH 1/2] some fancy features --- blink.ino | 54 +++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 39 insertions(+), 15 deletions(-) diff --git a/blink.ino b/blink.ino index 54d7e426..9f7a34c1 100644 --- a/blink.ino +++ b/blink.ino @@ -1,24 +1,48 @@ /* - Blink - Turns on an LED on for one second, then off for one second, repeatedly. + Blink - Enhanced Version + Creates a fancy blinking pattern with variable delays and brightness levels. + Perfect for testing GitHub PR workflows! This example code is in the public domain. */ - -// Pin 13 has an LED connected on most Arduino boards. -// give it a name: -int led = 13; -// the setup routine runs once when you press reset: -void setup() { - // initialize the digital pin as an output. - pinMode(led, OUTPUT); +// Constants for pin and timing configurations +const int LED_PIN = 13; // Most Arduino boards have built-in LED on pin 13 +const int FADE_STEPS = 5; +const int FADE_DELAY = 50; + +// Global variables for LED state +int brightness = 0; +bool increasing = true; + +void setup() { + // Initialize LED pin and serial communication + pinMode(LED_PIN, OUTPUT); + Serial.begin(9600); // For debugging + Serial.println("Fancy Blink Pattern Started!"); } -// the loop routine runs over and over again forever: void loop() { - digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level) - delay(1000); // wait for a second - digitalWrite(led, LOW); // turn the LED off by making the voltage LOW - delay(2000); // wait for a second + // Fancy fade effect + if (increasing) { + brightness += 51; // 255/5 steps = 51 per step + if (brightness >= 255) { + brightness = 255; + increasing = false; + } + } else { + brightness -= 51; + if (brightness <= 0) { + brightness = 0; + increasing = true; + } + } + + analogWrite(LED_PIN, brightness); // PWM output for smooth fading + delay(FADE_DELAY); // Short delay for smooth animation + + // Add a pause at min/max brightness + if (brightness == 0 || brightness == 255) { + delay(500); // Dramatic pause! + } } From f7f4c93fc92a036045b8c8dbacc5c01e08c05c15 Mon Sep 17 00:00:00 2001 From: Petr Koklev Date: Thu, 5 Jun 2025 10:47:45 +0300 Subject: [PATCH 2/2] changes done --- blink.ino | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/blink.ino b/blink.ino index 9f7a34c1..0990d77e 100644 --- a/blink.ino +++ b/blink.ino @@ -9,7 +9,8 @@ // Constants for pin and timing configurations const int LED_PIN = 13; // Most Arduino boards have built-in LED on pin 13 const int FADE_STEPS = 5; -const int FADE_DELAY = 50; +const int FADE_DELAY = 30; // Reduced delay for faster animation +const int PAUSE_DELAY = 300; // Shorter dramatic pause // Global variables for LED state int brightness = 0; @@ -23,26 +24,26 @@ void setup() { } void loop() { - // Fancy fade effect + // Implement smoother fading with smaller steps if (increasing) { - brightness += 51; // 255/5 steps = 51 per step + brightness += 25; // Smaller steps for smoother transition if (brightness >= 255) { brightness = 255; increasing = false; } } else { - brightness -= 51; + brightness -= 25; if (brightness <= 0) { - brightness = 0; + brightness = 0; increasing = true; } } - analogWrite(LED_PIN, brightness); // PWM output for smooth fading - delay(FADE_DELAY); // Short delay for smooth animation + analogWrite(LED_PIN, brightness); + delay(FADE_DELAY); - // Add a pause at min/max brightness + // Add shorter pause at min/max brightness if (brightness == 0 || brightness == 255) { - delay(500); // Dramatic pause! + delay(PAUSE_DELAY); } }