Advertisement
pleasedontcode

Time Control rev_02

Apr 27th, 2024
83
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: Time Control
  13.     - Source Code NOT compiled for: Arduino Uno
  14.     - Source Code created on: 2024-04-27 15:55:14
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* turn on for 30 sec then stop and repeat cycle */
  21. /****** SYSTEM REQUIREMENT 2 *****/
  22.     /* In a continuous cycle, Turn on LED for 30 seconds */
  23.     /* then stop for 10 seconds */
  24. /****** END SYSTEM REQUIREMENTS *****/
  25.  
  26. /****** DEFINITION OF LIBRARIES *****/
  27. #include <Servo.h>  // https://github.com/arduino-libraries/Servo
  28.  
  29. /****** FUNCTION PROTOTYPES *****/
  30. void setup(void);
  31. void loop(void);
  32. void updateOutputs(void);
  33.  
  34. /***** DEFINITION OF DIGITAL OUTPUT PINS *****/
  35. const uint8_t led_LEDRGB_Red_PIN_D2        = 2;
  36.  
  37. /***** DEFINITION OF PWM OUTPUT PINS *****/
  38. const uint8_t Servo_Servomotor_PWMSignal_PIN_D3    = 3;
  39.  
  40. /***** DEFINITION OF OUTPUT RAW VARIABLES *****/
  41. bool    led_LEDRGB_Red_PIN_D2_rawData        = 0;
  42. uint8_t Servo_Servomotor_PWMSignal_PIN_D3_rawData    = 0;
  43.  
  44. /***** DEFINITION OF OUTPUT PHYSICAL VARIABLES *****/
  45. float   led_LEDRGB_Red_PIN_D2_phyData        = 0.0;
  46. float   Servo_Servomotor_PWMSignal_PIN_D3_phyData    = 0.0;
  47.  
  48. /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
  49. Servo myservo; // Create a Servo object
  50.  
  51. void setup(void)
  52. {
  53.     // put your setup code here, to run once:
  54.  
  55.     pinMode(led_LEDRGB_Red_PIN_D2,   OUTPUT);
  56.     pinMode(Servo_Servomotor_PWMSignal_PIN_D3, OUTPUT);
  57.  
  58.     myservo.attach(Servo_Servomotor_PWMSignal_PIN_D3); // Attach the Servo object to the PWM pin
  59. }
  60.  
  61. void loop(void)
  62. {
  63.     // put your main code here, to run repeatedly:
  64.  
  65.     unsigned long currentMillis = millis();
  66.  
  67.     if (currentMillis % 40000 < 30000) {
  68.         // Turn on LED for 30 seconds
  69.         led_LEDRGB_Red_PIN_D2_rawData = HIGH;
  70.     } else {
  71.         // Stop LED for 10 seconds
  72.         led_LEDRGB_Red_PIN_D2_rawData = LOW;
  73.     }
  74.  
  75.     updateOutputs(); // Refresh output data
  76. }
  77.  
  78. void updateOutputs()
  79. {
  80.     digitalWrite(led_LEDRGB_Red_PIN_D2, led_LEDRGB_Red_PIN_D2_rawData);
  81.     analogWrite(Servo_Servomotor_PWMSignal_PIN_D3, Servo_Servomotor_PWMSignal_PIN_D3_rawData);
  82. }
  83.  
  84. /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement