Skip to content

some fancy features #1514

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 40 additions & 15 deletions blink.ino
Original file line number Diff line number Diff line change
@@ -1,24 +1,49 @@
/*
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 = 30; // Reduced delay for faster animation
const int PAUSE_DELAY = 300; // Shorter dramatic pause

// 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
// Implement smoother fading with smaller steps
if (increasing) {
brightness += 25; // Smaller steps for smoother transition
if (brightness >= 255) {
brightness = 255;
increasing = false;
}
} else {
brightness -= 25;
if (brightness <= 0) {
brightness = 0;
increasing = true;
}
}

analogWrite(LED_PIN, brightness);
delay(FADE_DELAY);

// Add shorter pause at min/max brightness
if (brightness == 0 || brightness == 255) {
delay(PAUSE_DELAY);
}
}