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: **Matrix Control**
- - Source Code NOT compiled for: Arduino Uno
- - Source Code created on: 2025-01-03 14:36:18
- ********* Pleasedontcode.com **********/
- /****** SYSTEM REQUIREMENTS *****/
- /****** SYSTEM REQUIREMENT 1 *****/
- /* This project integrates an EasyButton for button */
- /* presses and a MAX7219 LED matrix for displaying */
- /* information. A potentiometer is used for adjusting */
- /* settings, enhancing user experience through real- */
- /* time feedback. */
- /****** END SYSTEM REQUIREMENTS *****/
- /* START CODE */
- /****** DEFINITION OF LIBRARIES *****/
- #include <EasyButton.h> //https://github.com/evert-arias/EasyButton
- #include <Led-Matrix-SOLDERED.h> //https://github.com/SolderedElectronics/Soldered-8x8-MAX7219-LED-Matrix-Arduino-Library
- /****** FUNCTION PROTOTYPES *****/
- void setup(void);
- void loop(void);
- /***** DEFINITION OF DIGITAL INPUT PINS *****/
- const uint8_t f_PushButton_PIN_D2 = 2;
- /***** DEFINITION OF ANALOG INPUT PINS *****/
- const uint8_t m_Potentiometer_Vout_PIN_A0 = A0;
- /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
- // Instantiate EasyButton for handling button presses
- EasyButton button(f_PushButton_PIN_D2);
- // Instantiate Led_Matrix for controlling the LED matrix
- Led_Matrix ledMatrix(10, 1); // Assuming CS pin is 10 and 1 device
- void setup(void)
- {
- // Initialize button
- button.begin();
- // Initialize LED matrix
- ledMatrix.begin();
- // Set up pin modes
- pinMode(f_PushButton_PIN_D2, INPUT_PULLUP);
- pinMode(m_Potentiometer_Vout_PIN_A0, INPUT);
- }
- void loop(void)
- {
- // Update button state
- button.read();
- button.update();
- // Read potentiometer value
- int potValue = analogRead(m_Potentiometer_Vout_PIN_A0);
- // Use the potentiometer value to adjust LED brightness or other settings
- // For demonstration, we will display the potentiometer value on the LED matrix
- ledMatrix.clear();
- ledMatrix.setCursor(0, 0);
- ledMatrix.print(potValue);
- ledMatrix.write();
- // Check button press
- if (button.pressed()) {
- // Display a message when the button is pressed
- ledMatrix.clear();
- ledMatrix.setCursor(0, 0);
- ledMatrix.print("Button Pressed");
- ledMatrix.write();
- }
- delay(100); // Small delay to debounce
- }
- /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement