Advertisement
pleasedontcode

Trafficlightcontroller rev_01

Nov 20th, 2023
86
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: Trafficlightcontroller
  13.     - Source Code compiled for: Arduino Uno
  14.     - Source Code created on: 2023-11-21 00:50:22
  15.     - Source Code generated by: electronics
  16.  
  17. ********* Pleasedontcode.com **********/
  18. /****** DEFINITION OF LIBRARIES *****/
  19. #include <Arduino.h>
  20.  
  21. /****** SYSTEM REQUIREMENT 1 *****/
  22.     /* Turn green led for 10s and red for 5s  Blue for 5s */
  23. /****** SYSTEM REQUIREMENT 2 *****/
  24.     /* Turn green led for 10s and red for 5s  Blue for 5s */
  25.  
  26. /****** FUNCTION PROTOTYPES *****/
  27. void setup(void);
  28. void loop(void);
  29.  
  30. /***** DEFINITION OF DIGITAL OUTPUT PINS *****/
  31. const uint8_t Led_LEDRGB_Red_PIN_D2 = 2;   // Define pin D2 for red LED
  32. const uint8_t Led_LEDRGB_Green_PIN_D3 = 3; // Define pin D3 for green LED
  33. const uint8_t Led_LEDRGB_Blue_PIN_D4 = 4;  // Define pin D4 for blue LED
  34.  
  35. void setup(void)
  36. {
  37.     // Set the LED pins as outputs
  38.     pinMode(Led_LEDRGB_Red_PIN_D2, OUTPUT);
  39.     pinMode(Led_LEDRGB_Green_PIN_D3, OUTPUT);
  40.     pinMode(Led_LEDRGB_Blue_PIN_D4, OUTPUT);
  41. }
  42.  
  43. void loop(void)
  44. {
  45.     // System Requirement 1: Turn green LED on for 10 seconds, then red LED for 5 seconds, and blue LED for 5 seconds
  46.     digitalWrite(Led_LEDRGB_Green_PIN_D3, HIGH); // Turn on green LED
  47.     delay(10000);                               // Wait for 10 seconds
  48.     digitalWrite(Led_LEDRGB_Green_PIN_D3, LOW);  // Turn off green LED
  49.  
  50.     digitalWrite(Led_LEDRGB_Red_PIN_D2, HIGH);   // Turn on red LED
  51.     delay(5000);                                // Wait for 5 seconds
  52.     digitalWrite(Led_LEDRGB_Red_PIN_D2, LOW);    // Turn off red LED
  53.  
  54.     digitalWrite(Led_LEDRGB_Blue_PIN_D4, HIGH);  // Turn on blue LED
  55.     delay(5000);                                // Wait for 5 seconds
  56.     digitalWrite(Led_LEDRGB_Blue_PIN_D4, LOW);   // Turn off blue LED
  57.  
  58.     // System Requirement 2: Turn green LED on for 10 seconds, then red LED for 5 seconds, and blue LED for 5 seconds
  59.     digitalWrite(Led_LEDRGB_Green_PIN_D3, HIGH); // Turn on green LED
  60.     delay(10000);                               // Wait for 10 seconds
  61.     digitalWrite(Led_LEDRGB_Green_PIN_D3, LOW);  // Turn off green LED
  62.  
  63.     digitalWrite(Led_LEDRGB_Red_PIN_D2, HIGH);   // Turn on red LED
  64.     delay(5000);                                // Wait for 5 seconds
  65.     digitalWrite(Led_LEDRGB_Red_PIN_D2, LOW);    // Turn off red LED
  66.  
  67.     digitalWrite(Led_LEDRGB_Blue_PIN_D4, HIGH);  // Turn on blue LED
  68.     delay(5000);                                // Wait for 5 seconds
  69.     digitalWrite(Led_LEDRGB_Blue_PIN_D4, LOW);   // Turn off blue LED
  70. }
  71.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement