Advertisement
pleasedontcode

**LED Blinker** rev_01

Jan 7th, 2025
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /********* Pleasedontcode.com **********
  2.  
  3.     Pleasedontcode thanks you for automatic code generation! Enjoy your code!
  4.  
  5.     - Terms and Conditions:
  6.     You have a non-exclusive, revocable, worldwide, royalty-free license
  7.     for personal and commercial use. Attribution is optional; modifications
  8.     are allowed, but you're responsible for code maintenance. We're not
  9.     liable for any loss or damage. For full terms,
  10.     please visit pleasedontcode.com/termsandconditions.
  11.  
  12.     - Project: **LED Blinker**
  13.     - Source Code NOT compiled for: Arduino Uno
  14.     - Source Code created on: 2025-01-07 06:32:55
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* Add 2 more led output and blink a led in different */
  21.     /* timings with 3 seconds delay continuosly */
  22. /****** END SYSTEM REQUIREMENTS *****/
  23.  
  24. /* START CODE */
  25.  
  26. /****** DEFINITION OF LIBRARIES *****/
  27. #include <Arduino.h> // Include Arduino library for basic functions
  28.  
  29. /****** FUNCTION PROTOTYPES *****/
  30. void setup(void);
  31. void loop(void);
  32.  
  33. const int led1 = 13; // LED on pin 13
  34. const int led2 = 12; // LED on pin 12
  35. const int led3 = 11; // LED on pin 11
  36.  
  37. void setup(void)
  38. {
  39.   // put your setup code here, to run once:
  40.   pinMode(led1, OUTPUT); // Set pin 13 as an output for the first LED
  41.   pinMode(led2, OUTPUT); // Set pin 12 as an output for the second LED
  42.   pinMode(led3, OUTPUT); // Set pin 11 as an output for the third LED
  43.   Serial.begin(9600);    // Initialize serial communication at 9600 baud
  44. }
  45.  
  46. void loop(void)
  47. {
  48.   // Blink the first LED
  49.   digitalWrite(led1, HIGH); // Turn the first LED on
  50.   delay(1000);              // Wait for 1 second
  51.   Serial.write("LED 1 ON"); // Send "LED 1 ON" to the serial port
  52.   digitalWrite(led1, LOW);  // Turn the first LED off
  53.   delay(1000);              // Wait for 1 second
  54.   Serial.write("LED 1 OFF"); // Send "LED 1 OFF" to the serial port
  55.  
  56.   // Blink the second LED
  57.   digitalWrite(led2, HIGH); // Turn the second LED on
  58.   delay(2000);              // Wait for 2 seconds
  59.   Serial.write("LED 2 ON"); // Send "LED 2 ON" to the serial port
  60.   digitalWrite(led2, LOW);  // Turn the second LED off
  61.   delay(2000);              // Wait for 2 seconds
  62.   Serial.write("LED 2 OFF"); // Send "LED 2 OFF" to the serial port
  63.  
  64.   // Blink the third LED
  65.   digitalWrite(led3, HIGH); // Turn the third LED on
  66.   delay(3000);              // Wait for 3 seconds
  67.   Serial.write("LED 3 ON"); // Send "LED 3 ON" to the serial port
  68.   digitalWrite(led3, LOW);  // Turn the third LED off
  69.   delay(3000);              // Wait for 3 seconds
  70.   Serial.write("LED 3 OFF"); // Send "LED 3 OFF" to the serial port
  71. }
  72.  
  73. /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement