Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /********* Pleasedontcode.com **********
- Pleasedontcode thanks you for automatic code generation! Enjoy your code!
- - Terms and Conditions:
- You have a non-exclusive, revocable, worldwide, royalty-free license
- for personal and commercial use. Attribution is optional; modifications
- are allowed, but you're responsible for code maintenance. We're not
- liable for any loss or damage. For full terms,
- please visit pleasedontcode.com/termsandconditions.
- - Project: **Firework Display**
- - Source Code NOT compiled for: ESP32 DevKit V1
- - Source Code created on: 2025-01-30 06:57:12
- ********* Pleasedontcode.com **********/
- /****** SYSTEM REQUIREMENTS *****/
- /****** SYSTEM REQUIREMENT 1 *****/
- /* 在屏幕中显示释放烟花的全过程 */
- /****** END SYSTEM REQUIREMENTS *****/
- /* START CODE */
- /****** DEFINITION OF LIBRARIES *****/
- #include <Wire.h>
- #include <Adafruit_SSD1306.h> //https://github.com/stblassitude/Adafruit_SSD1306_Wemos_OLED.git
- #include <U8g2_for_Adafruit_GFX.h> //https://github.com/olikraus/U8g2_for_Adafruit_GFX
- /****** FUNCTION PROTOTYPES *****/
- void setup(void);
- void loop(void);
- void displayFireworkProcess(int step);
- /***** DEFINITION OF I2C PINS *****/
- const uint8_t SSD1306OledDisplay_I2C_PIN_SDA = 21;
- const uint8_t SSD1306OledDisplay_I2C_PIN_SCL = 22;
- const uint8_t SSD1306OledDisplay_I2C_SLAVE_ADDRESS = 60;
- /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
- Adafruit_SSD1306 display(128, 32, &Wire, -1); // Create display object
- void setup(void)
- {
- // Initialize the display
- display.begin(SSD1306_SWITCHCAPVCC, SSD1306OledDisplay_I2C_SLAVE_ADDRESS);
- display.clearDisplay();
- display.setTextSize(1);
- display.setTextColor(SSD1306_WHITE);
- display.display();
- }
- void loop(void)
- {
- // Simulate the firework process
- for (int step = 0; step < 10; step++) {
- displayFireworkProcess(step);
- delay(1000); // Wait for a second between steps
- }
- }
- void displayFireworkProcess(int step)
- {
- display.clearDisplay(); // Clear the display
- // Display different stages of the firework process
- display.setCursor(0, 0);
- display.print("Firework Process:");
- display.setCursor(0, 10);
- switch (step) {
- case 0:
- display.print("Preparing...");
- break;
- case 1:
- display.print("Lighting Fuse...");
- break;
- case 2:
- display.print("Launching...");
- break;
- case 3:
- display.print("In the Air!");
- break;
- case 4:
- display.print("Exploding!");
- break;
- case 5:
- display.print("Colors!");
- break;
- case 6:
- display.print("Sparkles!");
- break;
- case 7:
- display.print("Finale!");
- break;
- case 8:
- display.print("Fading...");
- break;
- case 9:
- display.print("Done!");
- break;
- }
- display.display(); // Update the display with the new content
- }
- /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement