Advertisement
pleasedontcode

**Firework Display** rev_03

Jan 30th, 2025
55
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: **Firework Display**
  13.     - Source Code NOT compiled for: ESP32 DevKit V1
  14.     - Source Code created on: 2025-01-30 06:57:12
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* 在屏幕中显示释放烟花的全过程 */
  21. /****** END SYSTEM REQUIREMENTS *****/
  22.  
  23. /* START CODE */
  24.  
  25. /****** DEFINITION OF LIBRARIES *****/
  26. #include <Wire.h>
  27. #include <Adafruit_SSD1306.h>   //https://github.com/stblassitude/Adafruit_SSD1306_Wemos_OLED.git
  28. #include <U8g2_for_Adafruit_GFX.h>  //https://github.com/olikraus/U8g2_for_Adafruit_GFX
  29.  
  30. /****** FUNCTION PROTOTYPES *****/
  31. void setup(void);
  32. void loop(void);
  33. void displayFireworkProcess(int step);
  34.  
  35. /***** DEFINITION OF I2C PINS *****/
  36. const uint8_t SSD1306OledDisplay_I2C_PIN_SDA = 21;
  37. const uint8_t SSD1306OledDisplay_I2C_PIN_SCL = 22;
  38. const uint8_t SSD1306OledDisplay_I2C_SLAVE_ADDRESS = 60;
  39.  
  40. /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
  41. Adafruit_SSD1306 display(128, 32, &Wire, -1); // Create display object
  42.  
  43. void setup(void)
  44. {
  45.     // Initialize the display
  46.     display.begin(SSD1306_SWITCHCAPVCC, SSD1306OledDisplay_I2C_SLAVE_ADDRESS);
  47.     display.clearDisplay();
  48.     display.setTextSize(1);
  49.     display.setTextColor(SSD1306_WHITE);
  50.     display.display();
  51. }
  52.  
  53. void loop(void)
  54. {
  55.     // Simulate the firework process
  56.     for (int step = 0; step < 10; step++) {
  57.         displayFireworkProcess(step);
  58.         delay(1000); // Wait for a second between steps
  59.     }
  60. }
  61.  
  62. void displayFireworkProcess(int step)
  63. {
  64.     display.clearDisplay(); // Clear the display
  65.  
  66.     // Display different stages of the firework process
  67.     display.setCursor(0, 0);
  68.     display.print("Firework Process:");
  69.     display.setCursor(0, 10);
  70.    
  71.     switch (step) {
  72.         case 0:
  73.             display.print("Preparing...");
  74.             break;
  75.         case 1:
  76.             display.print("Lighting Fuse...");
  77.             break;
  78.         case 2:
  79.             display.print("Launching...");
  80.             break;
  81.         case 3:
  82.             display.print("In the Air!");
  83.             break;
  84.         case 4:
  85.             display.print("Exploding!");
  86.             break;
  87.         case 5:
  88.             display.print("Colors!");
  89.             break;
  90.         case 6:
  91.             display.print("Sparkles!");
  92.             break;
  93.         case 7:
  94.             display.print("Finale!");
  95.             break;
  96.         case 8:
  97.             display.print("Fading...");
  98.             break;
  99.         case 9:
  100.             display.print("Done!");
  101.             break;
  102.     }
  103.  
  104.     display.display(); // Update the display with the new content
  105. }
  106.  
  107. /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement