Advertisement
pleasedontcode

"LED Control" rev_01

Jan 7th, 2025
59
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: ESP8266 NodeMCU V1.0
  14.     - Source Code created on: 2025-01-07 19:39:01
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* create a control library for prayer times and the */
  21.     /* current time on an LED display (like NeoPixel), as */
  22.     /* well as displaying other data such as temperature */
  23.     /* and humidity, you can structure the library in an */
  24.     /* organized way. I'll help you outline the structur */
  25. /****** END SYSTEM REQUIREMENTS *****/
  26.  
  27. /* START CODE */
  28.  
  29. /****** DEFINITION OF LIBRARIES *****/
  30. #include <Adafruit_NeoPixel.h> // https://github.com/adafruit/Adafruit_NeoPixel
  31.  
  32. // Define constants for the number of pixels and the pin connected to the NeoPixel strip
  33. #define NUM_PIXELS 60
  34. #define PIN 6
  35.  
  36. // Create an instance of the Adafruit_NeoPixel class
  37. Adafruit_NeoPixel pixels(NUM_PIXELS, PIN, NEO_GRB + NEO_KHZ800);
  38.  
  39. // Define digit patterns for displaying numbers on the LED display
  40. const uint8_t digitPatterns[10][7] = {
  41.   {1, 1, 1, 1, 1, 1, 0}, // 0
  42.   {0, 1, 1, 0, 0, 0, 0}, // 1
  43.   {1, 1, 0, 1, 1, 0, 1}, // 2
  44.   {1, 1, 1, 1, 0, 0, 1}, // 3
  45.   {0, 1, 1, 0, 0, 1, 1}, // 4
  46.   {1, 0, 1, 1, 0, 1, 1}, // 5
  47.   {1, 0, 1, 1, 1, 1, 1}, // 6
  48.   {1, 1, 1, 0, 0, 0, 0}, // 7
  49.   {1, 1, 1, 1, 1, 1, 1}, // 8
  50.   {1, 1, 1, 1, 0, 1, 1}  // 9
  51. };
  52.  
  53. // Function prototypes
  54. void displayTime(int hour, int minute, int second);
  55. void displayPrayerTimes(int fajrHour, int fajrMinute, int duhrHour, int duhrMinute, int asrHour, int asrMinute, int maghribHour, int maghribMinute, int ishaHour, int ishaMinute);
  56. void displayTemperature(float temperature);
  57. void displayHumidity(float humidity);
  58.  
  59. void setup(void)
  60. {
  61.     // Initialize the NeoPixel strip
  62.     pixels.begin();
  63.     pixels.show(); // Initialize all pixels to 'off'
  64. }
  65.  
  66. void loop(void)
  67. {
  68.     // Example usage of display functions
  69.     displayTime(12, 30, 45); // Display current time
  70.     delay(1000);
  71.     displayPrayerTimes(5, 15, 12, 30, 15, 45, 18, 0, 19, 15); // Display prayer times
  72.     delay(1000);
  73.     displayTemperature(25.5); // Display temperature
  74.     delay(1000);
  75.     displayHumidity(60.0); // Display humidity
  76.     delay(1000);
  77. }
  78.  
  79. // Function to display the current time on the LED display
  80. void displayTime(int hour, int minute, int second) {
  81.     // Implement the logic to display the time using the digitPatterns
  82.     // This is a placeholder for the actual implementation
  83. }
  84.  
  85. // Function to display prayer times on the LED display
  86. void displayPrayerTimes(int fajrHour, int fajrMinute, int duhrHour, int duhrMinute, int asrHour, int asrMinute, int maghribHour, int maghribMinute, int ishaHour, int ishaMinute) {
  87.     // Implement the logic to display the prayer times using the digitPatterns
  88.     // This is a placeholder for the actual implementation
  89. }
  90.  
  91. // Function to display temperature on the LED display
  92. void displayTemperature(float temperature) {
  93.     // Implement the logic to display the temperature
  94.     // This is a placeholder for the actual implementation
  95. }
  96.  
  97. // Function to display humidity on the LED display
  98. void displayHumidity(float humidity) {
  99.     // Implement the logic to display the humidity
  100.     // This is a placeholder for the actual implementation
  101. }
  102.  
  103. /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement