/*
MSJ Researchers World
Date - 21st OCT 2024
Mentor - Mr. Siranjeevi M
Contact - 7373771991
*/
// Pin assignments
const int ledPin = 5;
// Brightness level (0 to 255)
int brightness = 0;
// Fade amount for each step
int fadeAmount = 5;
void setup() {
// Set the LED pin as an output
pinMode(ledPin, OUTPUT);
}
void loop() {
// Set the brightness of the LED
analogWrite(ledPin, brightness);
// Change the brightness for the next loop
brightness = brightness + fadeAmount;
// Reverse the direction of the fade if limits are reached
if (brightness <= 0 || brightness >= 255) {
fadeAmount = -fadeAmount;
}
// Wait for a short period to see the fade effect
delay(30);
}