Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /********* Pleasedontcode.com **********
- Pleasedontcode thanks you for automatic code generation! Enjoy your code!
- - Terms and Conditions:
- You have a non-exclusive, revocable, worldwide, royalty-free license
- for personal and commercial use. Attribution is optional; modifications
- are allowed, but you're responsible for code maintenance. We're not
- liable for any loss or damage. For full terms,
- please visit pleasedontcode.com/termsandconditions.
- - Project: # LED Blink
- - Source Code NOT compiled for: Arduino Uno
- - Source Code created on: 2026-01-22 16:08:55
- ********* Pleasedontcode.com **********/
- /****** SYSTEM REQUIREMENTS *****/
- /****** SYSTEM REQUIREMENT 1 *****/
- /* Manage a lite LED component on Arduino Uno D2 pin */
- /* to enable basic lighting control with digital */
- /* output functionality for prototyping. */
- /****** END SYSTEM REQUIREMENTS *****/
- /****** DEFINITION OF LIBRARIES *****/
- // No external libraries required for basic digital output control
- /****** FUNCTION PROTOTYPES *****/
- void setup(void);
- void loop(void);
- void ledOn(void);
- void ledOff(void);
- void ledBlink(int blinkCount, int delayMs);
- /****** DEFINITION OF DIGITAL OUTPUT PINS *****/
- // LED Pin Variable - Lite LED connected to Arduino Uno D2 pin
- const int LED_PIN = 2; // LED connected to digital pin 2
- /*
- * setup() - This function runs once when you turn your Arduino on
- * We configure the D2 pin as a digital output for LED control
- */
- void setup()
- {
- // Set D2 pin to output mode for controlling the lite LED
- pinMode(LED_PIN, OUTPUT);
- // Initialize LED to OFF state
- digitalWrite(LED_PIN, LOW);
- }
- /*
- * loop() - This function will start after setup finishes and then repeat
- * Demonstrates basic LED control with blinking pattern
- */
- void loop()
- {
- // Turn LED on for 1 second
- ledOn();
- delay(1000);
- // Turn LED off for 1 second
- ledOff();
- delay(1000);
- // Blink the LED 3 times with 300ms interval
- ledBlink(3, 300);
- delay(1000);
- }
- /*
- * ledOn() - Turns on the lite LED on D2 pin
- * Provides digital HIGH output to enable the LED
- */
- void ledOn(void)
- {
- // Set D2 pin to HIGH to turn on the LED
- digitalWrite(LED_PIN, HIGH);
- }
- /*
- * ledOff() - Turns off the lite LED on D2 pin
- * Provides digital LOW output to disable the LED
- */
- void ledOff(void)
- {
- // Set D2 pin to LOW to turn off the LED
- digitalWrite(LED_PIN, LOW);
- }
- /*
- * ledBlink() - Blinks the lite LED on D2 pin
- * Parameters:
- * blinkCount - Number of times to blink the LED
- * delayMs - Delay in milliseconds between each blink state change
- */
- void ledBlink(int blinkCount, int delayMs)
- {
- // Perform the blink cycle the specified number of times
- for(int i = 0; i < blinkCount; i++)
- {
- // Turn LED on
- ledOn();
- delay(delayMs);
- // Turn LED off
- ledOff();
- delay(delayMs);
- }
- }
- /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment