Advertisement
pleasedontcode

"Color Cycle" rev_01

Dec 3rd, 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: "Color Cycle"
  13.     - Source Code NOT compiled for: Arduino Uno
  14.     - Source Code created on: 2024-12-03 20:34:56
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* its a led module */
  21. /****** END SYSTEM REQUIREMENTS *****/
  22.  
  23. /* START CODE */
  24.  
  25. /****** DEFINITION OF LIBRARIES *****/
  26. #include <Arduino.h> // Include Arduino library for basic functions
  27.  
  28. // Define pins for RGB LED
  29. #define RED_PIN 9
  30. #define GREEN_PIN 10
  31. #define BLUE_PIN 11
  32.  
  33. // Define variables for RGB values
  34. int redValue = 0;
  35. int greenValue = 0;
  36. int blueValue = 0;
  37.  
  38. /****** FUNCTION PROTOTYPES *****/
  39. void setup(void);
  40. void loop(void);
  41.  
  42. void setup(void)
  43. {
  44.     // Set RGB pins as output
  45.     pinMode(RED_PIN, OUTPUT);
  46.     pinMode(GREEN_PIN, OUTPUT);
  47.     pinMode(BLUE_PIN, OUTPUT);
  48. }
  49.  
  50. void loop(void)
  51. {
  52.     // Set RGB values to random values between 0 and 255
  53.     redValue = random(0, 256); // Changed to 256 to include 255
  54.     greenValue = random(0, 256); // Changed to 256 to include 255
  55.     blueValue = random(0, 256); // Changed to 256 to include 255
  56.  
  57.     // Write RGB values to corresponding pins
  58.     analogWrite(RED_PIN, redValue);
  59.     analogWrite(GREEN_PIN, greenValue);
  60.     analogWrite(BLUE_PIN, blueValue);
  61.  
  62.     // Delay for 1 second
  63.     delay(1000);
  64. }
  65.  
  66. /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement