Advertisement
pleasedontcode

**Matrix Control** rev_01

Jan 3rd, 2025
234
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: **Matrix Control**
  13.     - Source Code NOT compiled for: Arduino Uno
  14.     - Source Code created on: 2025-01-03 14:36:18
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* This project integrates an EasyButton for button */
  21.     /* presses and a MAX7219 LED matrix for displaying */
  22.     /* information. A potentiometer is used for adjusting */
  23.     /* settings, enhancing user experience through real- */
  24.     /* time feedback. */
  25. /****** END SYSTEM REQUIREMENTS *****/
  26.  
  27. /* START CODE */
  28.  
  29. /****** DEFINITION OF LIBRARIES *****/
  30. #include <EasyButton.h> //https://github.com/evert-arias/EasyButton
  31. #include <Led-Matrix-SOLDERED.h>    //https://github.com/SolderedElectronics/Soldered-8x8-MAX7219-LED-Matrix-Arduino-Library
  32.  
  33. /****** FUNCTION PROTOTYPES *****/
  34. void setup(void);
  35. void loop(void);
  36.  
  37. /***** DEFINITION OF DIGITAL INPUT PINS *****/
  38. const uint8_t f_PushButton_PIN_D2 = 2;
  39.  
  40. /***** DEFINITION OF ANALOG INPUT PINS *****/
  41. const uint8_t m_Potentiometer_Vout_PIN_A0 = A0;
  42.  
  43. /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
  44. // Instantiate EasyButton for handling button presses
  45. EasyButton button(f_PushButton_PIN_D2);
  46.  
  47. // Instantiate Led_Matrix for controlling the LED matrix
  48. Led_Matrix ledMatrix(10, 1); // Assuming CS pin is 10 and 1 device
  49.  
  50. void setup(void)
  51. {
  52.     // Initialize button
  53.     button.begin();
  54.  
  55.     // Initialize LED matrix
  56.     ledMatrix.begin();
  57.  
  58.     // Set up pin modes
  59.     pinMode(f_PushButton_PIN_D2, INPUT_PULLUP);
  60.     pinMode(m_Potentiometer_Vout_PIN_A0, INPUT);
  61. }
  62.  
  63. void loop(void)
  64. {
  65.     // Update button state
  66.     button.read();
  67.     button.update();
  68.  
  69.     // Read potentiometer value
  70.     int potValue = analogRead(m_Potentiometer_Vout_PIN_A0);
  71.  
  72.     // Use the potentiometer value to adjust LED brightness or other settings
  73.     // For demonstration, we will display the potentiometer value on the LED matrix
  74.     ledMatrix.clear();
  75.     ledMatrix.setCursor(0, 0);
  76.     ledMatrix.print(potValue);
  77.     ledMatrix.write();
  78.  
  79.     // Check button press
  80.     if (button.pressed()) {
  81.         // Display a message when the button is pressed
  82.         ledMatrix.clear();
  83.         ledMatrix.setCursor(0, 0);
  84.         ledMatrix.print("Button Pressed");
  85.         ledMatrix.write();
  86.     }
  87.  
  88.     delay(100); // Small delay to debounce
  89. }
  90.  
  91. /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement