Advertisement
pleasedontcode

LED Control rev_02

Nov 2nd, 2024
35
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 Control
  13.     - Source Code NOT compiled for: Arduino Uno
  14.     - Source Code created on: 2024-11-02 06:30:47
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* control red led connecter to pin D2 , the led */
  21.     /* switch on 2second then switch off after that the */
  22.     /* second green led switch on then wait 2 second then */
  23.     /* switch off */
  24. /****** END SYSTEM REQUIREMENTS *****/
  25.  
  26. /****** DEFINITION OF LIBRARIES *****/
  27.  
  28. /****** FUNCTION PROTOTYPES *****/
  29. void setup(void);
  30. void loop(void);
  31. void updateOutputs(void);
  32.  
  33. /***** DEFINITION OF DIGITAL OUTPUT PINS *****/
  34. const uint8_t led_LED_PIN_D2 = 2; // Red LED connected to pin D2
  35. const uint8_t green_led_LED_PIN_D3 = 3; // Green LED connected to pin D3
  36.  
  37. /***** DEFINITION OF OUTPUT RAW VARIABLES *****/
  38. /***** used to store raw data *****/
  39. bool led_LED_PIN_D2_rawData = 0; // Initial state for Red LED
  40. bool green_led_LED_PIN_D3_rawData = 0; // Initial state for Green LED
  41.  
  42. /***** DEFINITION OF OUTPUT PHYSICAL VARIABLES *****/
  43. /***** used to store data after characteristic curve transformation *****/
  44. float led_LED_PIN_D2_phyData = 0.0;
  45. float green_led_LED_PIN_D3_phyData = 0.0;
  46.  
  47. void setup(void)
  48. {
  49.     // Initialize the digital pins as outputs
  50.     pinMode(led_LED_PIN_D2, OUTPUT);
  51.     pinMode(green_led_LED_PIN_D3, OUTPUT);
  52. }
  53.  
  54. void loop(void)
  55. {
  56.     // Control the Red LED
  57.     led_LED_PIN_D2_rawData = true; // Turn on Red LED
  58.     updateOutputs(); // Refresh output data
  59.     delay(2000); // Wait for 2 seconds
  60.  
  61.     led_LED_PIN_D2_rawData = false; // Turn off Red LED
  62.     updateOutputs(); // Refresh output data
  63.  
  64.     // Control the Green LED
  65.     green_led_LED_PIN_D3_rawData = true; // Turn on Green LED
  66.     updateOutputs(); // Refresh output data
  67.     delay(2000); // Wait for 2 seconds
  68.  
  69.     green_led_LED_PIN_D3_rawData = false; // Turn off Green LED
  70.     updateOutputs(); // Refresh output data
  71.     delay(2000); // Wait for 2 seconds
  72. }
  73.  
  74. void updateOutputs()
  75. {
  76.     // Update the state of the LEDs
  77.     digitalWrite(led_LED_PIN_D2, led_LED_PIN_D2_rawData);
  78.     digitalWrite(green_led_LED_PIN_D3, green_led_LED_PIN_D3_rawData);
  79. }
  80.  
  81. /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement