Archives
Trending
Support
Login
clear text
XML
Django
JavaScript
MATLAB
C
C++
C#
Python
SQL
Shell
Bash
Markdown
YAML
JSON
HTML
CSS
PHP
Java
Ruby
Go
Rust
Swift
Kotlin
Arduino
TypeScript
Perl
Autohotkey
Lua
SQF
R
Scala
Haskell
Groovy
Dart
Clojure
VB.NET
Objective-C
PowerShell
Bash
CoffeeScript
Verilog
/********* 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: Display Control - Source Code NOT compiled for: ESP32 DevKit V1 - Source Code created on: 2024-08-18 19:07:27 ********* Pleasedontcode.com **********/ /****** SYSTEM REQUIREMENTS *****/ /****** SYSTEM REQUIREMENT 1 *****/ /* Utilize Wokwi to interface a MAX7219 Dot Matrix */ /* display with ESP32. Create a scrolling 9-character */ /* message, incorporate an LED and push button, and */ /* display button press status on the MAX7219. */ /****** END SYSTEM REQUIREMENTS *****/ /****** DEFINITION OF LIBRARIES *****/ #include
// https://github.com/evert-arias/EasyButton #include
// Include the library for MAX7219 Dot Matrix display #include
// Include SPI library for communication with MAX7219 /****** FUNCTION PROTOTYPES *****/ void setup(void); void loop(void); /***** DEFINITION OF DIGITAL INPUT PINS *****/ const uint8_t nn_PushButton_PIN_D4 = 4; // Pin for button D4 const uint8_t nn_PushButton_PIN_D13 = 13; // Pin for button D13 /***** DEFINITION OF MAX7219 DISPLAY PINS *****/ #define MAX_DEVICES 1 // Number of MAX7219 devices #define DATA_IN 23 // Data pin connected to MAX7219 #define CLK_PIN 18 // Clock pin connected to MAX7219 #define LOAD_PIN 5 // Load pin connected to MAX7219 /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/ // Create instances of EasyButton for each button EasyButton buttonD4(nn_PushButton_PIN_D4); // Instance for button on pin D4 EasyButton buttonD13(nn_PushButton_PIN_D13); // Instance for button on pin D13 // Create an instance of the MAX7219 display MD_MAX72XX display = MD_MAX72XX(DATA_IN, CLK_PIN, LOAD_PIN, MAX_DEVICES); // Callback function for button D4 pressed void onButtonD4Pressed() { Serial.println("Button D4 pressed"); display.clear(); // Clear the display display.print("D4 Pressed"); // Show button press status } // Callback function for button D13 pressed void onButtonD13Pressed() { Serial.println("Button D13 pressed"); display.clear(); // Clear the display display.print("D13 Pressed"); // Show button press status } // Function to scroll a message on the display void scrollMessage(const char* message) { display.clear(); display.setCursor(0, 0); display.print(message); display.update(); delay(1000); // Delay to allow the message to be visible } void setup(void) { // Initialize Serial for debugging purposes Serial.begin(115200); Serial.println(); Serial.println(">>> EasyButton example with multiple buttons <<<"); // Initialize the buttons buttonD4.begin(); // Initialize button on pin D4 buttonD13.begin(); // Initialize button on pin D13 // Add callback functions for button presses buttonD4.onPressed(onButtonD4Pressed); // Set callback for button D4 buttonD13.onPressed(onButtonD13Pressed); // Set callback for button D13 // Initialize the MAX7219 display display.begin(); display.setIntensity(5); // Set brightness level (0-15) display.clear(); // Clear the display at startup // Scroll a welcome message scrollMessage("Welcome!"); } void loop(void) { // Continuously read the status of the buttons buttonD4.read(); // Read the state of button D4 buttonD13.read(); // Read the state of button D13 }
Mark as private (unlisted)
for 30 minutes
for 6 hours
for 1 day
for 1 week
for 1 month
for 1 year
everlasting (like CCCP)