0

I am creating a 20x15 LED Matrix using and Arduino Nano. My goal is to switch between different "scenes," if you will, using 4 buttons (I just need to run different code to make it display something different). The four buttons share a ground, and they go into digital pins (I don't have resistors on the ground because of this article). Then in the code (under void loop) there is one big if-then tree. For example, if (button1State == HIGH) {} else {if (button2State == HIGH)} and so on and so forth.

When I connect the buttons, the lights flicker and glitch. Without the buttons, it goes to the last else completely fine, so I know my light code works. To me, the code looks fine, but I want to see if there is something that I am doing wrong. I wonder if putting the code in voids instead of them in the if-thens in the loop would be better, but I don't know how I would invoke them.

If anyone could figure out what I am doing wrong or something that could make my code better, I would be super grateful.

Here is my full, current code (ignore all of the comments, I am designing the code so someone with no coding knowledge could understand it)

//   HEY! LOOK UP HERE! I know it looks confusing, but don't worry, I'll help you! I'm Clippy! 
//    _________________
//   < I can help you! >
//    -----------------
//    \
//     \
//        __
//       /  \
//       |  |
//       @  @
//       |  |
//       || |/
//       || ||
//       |\_/|
//       \___/

//As you know, there are 4 buttons. When they are pressed, they display something different. We can make them display text as well.
//Below are VARIABLES, which control what text is displayed when buttons are pressed. Put what you want them to display between the 
//quotation marks. If you don't want anything in a button, just put a space inbetween them.

//Note: only button 1 and 3 can display text, so lets only put text in those :)
String buttonText1 = " "; //Again, put what you want button 1 to display in text
//String buttonText2 = " ";
String buttonText3 = " ";
//String buttonText4 = " ";
String defaultText = "   Text for the panel"; //This is what will show up when you first start it up

//Here we can adjust what the brightness of the panel is. We use a switch to do this. You can use values from 0 (lowest) to 255 (highest)
int switchLevel1 = 10;
int switchLevel2 = 200;

//Here we can control how many colors are on the backgrounds at one time. We can customize this to get some variety in our displays.
int colorsOnscreen1 = 5; //For button 1
//int colorsOnscreen2 = 3
int colorsOnscreen3 = 10; //For button 3
//int colorsOnscreen4 = 5;
int colorsOnscreenDefault = 3; //For when you start it up

int lastButton = 0; //Last button pressed stuff, gets fed to buttons


//----------------------------------------------------------------You Probably Don't Have To Worry About The Rest----------------------------------------------------------------

//This stuff you don't have to worry about, its for the board
#include <Adafruit_NeoPixel.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SPITFT.h>
#include <Adafruit_SPITFT_Macros.h>
#include <gfxfont.h>
#include <Adafruit_NeoMatrix.h>
#include <gamma.h>
#include "RGB.h"
#ifndef PSTR
 #define PSTR
#include smileytongue24.h
#include yellowsmiley24.h
#endif

#define PIN 3 // This is the pin where the data is coming out (you don't have to worry about this)

const int button1 = 4;     // the number of the arcade button pins
const int button2 = 5;
const int button3 = 6;
const int button4 = 7;
const int brightnessSwitch = 8;

// variables will change:
int button1State = 0;         // variable for reading the pushbutton status
int button2State = 0;
int button3State = 0;
int button4State = 0;
int switchState = 0;
int panelBrightness = 0;

//This stuff tells the board how the lights are arranged. In our case, it starts at the top left, and
//the signal goes right, and zigzags the rest of the way. It also tells it that it is 20 by 15 LEDs
Adafruit_NeoMatrix matrix = Adafruit_NeoMatrix(20, 15, PIN,
  NEO_MATRIX_TOP     + NEO_MATRIX_RIGHT +
  NEO_MATRIX_ROWS + NEO_MATRIX_ZIGZAG,
  NEO_GRB            + NEO_KHZ800);

void setup() {
  // initialize the buttons as inputs:
  pinMode(button1, INPUT);
  pinMode(button2, INPUT);
  pinMode(button3, INPUT);
  pinMode(button4, INPUT);
  pinMode(brightnessSwitch, INPUT);
  matrix.begin();
  matrix.setTextWrap(false);
  Serial.begin(9600);
  Serial.print("The LED Matrix has started. Default will be activated soon");
}

String panelText = buttonText1; //This is what text gets fed to the panel

int x    = matrix.width();
int pass = 0;

void loop() {
  matrix.setBrightness(panelBrightness); //This sets the overall brightness. 255 is the highest, while 0 is the lowest
  // read the state of the button:
  button1State = digitalRead(button1);
  button2State = digitalRead(button2);
  button3State = digitalRead(button4);
  button4State = digitalRead(button4);
  switchState = digitalRead(brightnessSwitch);
  if (switchState == HIGH){panelBrightness = switchLevel1;} else {panelBrightness = switchLevel2;} //Brightness Logic


  // if-then statements
  if (button1State == HIGH){ //BUTTON 1 CODE START
      static int i = 0; 
  i++;
  for(int y = 0; y < 15; y++)
    for(int x = 0; x < 20; x++)
      if(y & 1)
        matrix.setPixelColor(19 - x + y * 20, matrix.gamma32(matrix.ColorHSV((x + y) * 256 * colorsOnscreen1 + i * 128 * 2)));
      else
        matrix.setPixelColor(x + y * 20, matrix.gamma32(matrix.ColorHSV((x + y) * 256 * colorsOnscreen1 + i * 128 * 2)));

  matrix.setTextColor(matrix.Color(255, 255, 255)); //This determines the text color. If you want to set a text color, search in google "Color Picker" and use the RGB values in place of the numbers in (a,a,a)
  matrix.setCursor(-((millis() / 40) & 127), 4);
  matrix.print(buttonText1);
  matrix.show();
} 
//BUTTON 1 CODE END
   else {
      if (button2State == HIGH){ //BUTTON 2 CODE START
          //PUT WHAT HAPPENS FOR BUTTON 2 HERE
          //BUTTON 2 CODE END
      } else {
          if (button3State == HIGH){ //BUTTON CODE 3 START
                    static int i = 0; 
  i++;
  for(int y = 0; y < 15; y++)
    for(int x = 0; x < 20; x++)
      if(y & 1)
        matrix.setPixelColor(19 - x + y * 20, matrix.gamma32(matrix.ColorHSV((x - y) * 200 * colorsOnscreen3 + i * 128 * 2)));
      else
        matrix.setPixelColor(x + y * 20, matrix.gamma32(matrix.ColorHSV((x - y) * 256 * colorsOnscreen3 + i * 128 * 2)));

  matrix.setTextColor(matrix.Color(255, 255, 255)); //This determines the text color. If you want to set a text color, search in google "Color Picker" and use the RGB values in place of the numbers in (a,b,c)
  matrix.setCursor(-((millis() / 40) & 127), 4);
  matrix.print(buttonText3);
  matrix.show();
}
              //BUTTON 3 CODE END
           else {
              if (button4State == HIGH){ //BUTTON 4 CODE START
                  //PUT WHAT HAPPENS FOR BUTTON 4 HERE
                  //BUTTON 4 CODE END
              } else {
                  //WHAT HAPPENS UNTIL A BUTTON IS PRESSED


   static int i = 0;
  i++;
  //matrix.fillScreen(0);
  for(int y = 0; y < 15; y++)
    for(int x = 0; x < 20; x++)
      if(y & 1)
        matrix.setPixelColor(19 - x + y * 20, matrix.gamma32(matrix.ColorHSV((x + y) * 256 * colorsOnscreenDefault + i * 128 * 2)));
      else
        matrix.setPixelColor(x + y * 20, matrix.gamma32(matrix.ColorHSV((x + y) * 256 * colorsOnscreenDefault + i * 128 * 2)));

  matrix.setTextColor(matrix.Color(255, 255, 255)); //This determines the text color. If you want to set a text color, search in google "Color Picker" and use the RGB values in place of the numbers in (a,b,c)
  matrix.setCursor(-((millis() / 70) & 127), 4);
  matrix.println(defaultText);
  matrix.show();

}}}}


    }

Again, Thank You

-Micah

  • Do you have just the IO pin -> wire -> button -> wire -> ground? Nothing else connected to the button or IO pin? – Majenko Dec 31 '19 at 23:08
  • @Majenko Yup. I'm going to change it, but that is what I was doing. If it makes a difference, I also had all the grounds of the buttons tied together to one ground because my only other ground is being used to provide a ground consistent with the power supply for the data out. – Micah Wagoner Jan 1 at 17:14
2

I think your main problem is how you read the buttons.

  1. You simply connected the buttons with ground and the corresponding digital input pin on the Arduino without any extra components, just like the linked forum entry states. But you missed a very important part: The pullup resistor. When your button is pressed, the Arduinos pin will be pulled to ground. But if it is not pressed, there is nothing connected to the pin. Such a pin is called floating, as it does not have a fixed reference value. It will pick up whatever noise is floating around at it's location (often the state of other electronic parts or pins near it). It will change it's state erratically. You need to pull the pin to Vcc (5V in case of the Nano), so that the pin has a clear fixed state, when the button is not pressed. This can be done by either an external or the internal pullup resistor of the Atmega328P (the chip on the Nano). In the forum post the internal pullup is activated by doing a digitalWrite(pin, HIGH); after setting the pin to INPUT. But I think it is more speaking code to just use pinMode(pin, INPUT_PULLUP); which will do the same in one single step.

  2. In your code you check for the button pins to be HIGH, as if a button press would make the pin HIGH. But this is not the case, if you connect the button to ground. If pressed, the button will pull the pin to GROUND, thus a value of LOW. You need to check for the buttons to get LOW.

| improve this answer | |
  • Thank you for your fast and insightful response. Just to make sure I am interpreting your comment correctly, you are saying that if I use the internal pull up on the chip (using pinMode(pin, INPUT_PULLUP); , then I do not need to use an external pull up resistor because my button with already be not floating? Just trying to make sure I am interpreting this right. Again, thank you for the helpful response! – Micah Wagoner Jan 1 at 17:36
  • Yes, correct. You don't need an external pullup resistor, when you are activating the internal one. If nothing is connected to the pin, it will have the state HIGH, since the internal pullup will pull it to Vcc. When the button is pressed, the pin is connected to ground, thus has a state of LOW. A very little current will flow through the internal pullup resistor. – chrisl Jan 1 at 17:39
1

You should always comment your code, so that you will know what your code does when you look at it 6 months from now.

For beginners, you should not leave out the braces {} from any part of the code as you did in the for loops.

Here is your code correctly formatted, followed by a more cleaned up version which may be easier for beginner to follow.

Main question is whether the for loops are written as you intended.

Also, the use of if {} else { if {}} makes the code listing somewhat convoluted.

The second listing shows the if {} else if {} version.

//   HEY! LOOK UP HERE! I know it looks confusing, but don't worry, I'll help you! I'm Clippy!
//    _________________
//   < I can help you! >
//    -----------------
//    \
//     \
//        __
//       /  \
//       |  |
//       @  @
//       |  |
//       || |/
//       || ||
//       |\_/|
//       \___/

// As you know, there are 4 buttons. When they are pressed, they display something different. We can make them display text as well.
// Below are VARIABLES, which control what text is displayed when buttons are pressed. Put what you want them to display between the
// quotation marks. If you don't want anything in a button, just put a space inbetween them.

//Note: only button 1 and 3 can display text, so lets only put text in those :)
String buttonText1 = " "; //Again, put what you want button 1 to display in text
//String buttonText2 = " ";
String buttonText3 = " ";
//String buttonText4 = " ";
String defaultText = "   Text for the panel"; //This is what will show up when you first start it up

//Here we can adjust what the brightness of the panel is. We use a switch to do this. You can use values from 0 (lowest) to 255 (highest)
int switchLevel1 =  10;
int switchLevel2 = 200;

//Here we can control how many colors are on the backgrounds at one time. We can customize this to get some variety in our displays.
int colorsOnscreen1 = 5;           // For button 1
//int colorsOnscreen2 = 3
int colorsOnscreen3 = 10;          // For button 3
//int colorsOnscreen4 = 5;
int colorsOnscreenDefault = 3;     // For when you start it up

int lastButton = 0;                // Last button pressed stuff, gets fed to buttons


//----------------------------------------------------------------You Probably Don't Have To Worry About The Rest----------------------------------------------------------------

//This stuff you don't have to worry about, its for the board
#include <Adafruit_NeoPixel.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SPITFT.h>
#include <Adafruit_SPITFT_Macros.h>
#include <gfxfont.h>
#include <Adafruit_NeoMatrix.h>
#include <gamma.h>
#include "RGB.h"
#ifndef PSTR
 #define PSTR
#include smileytongue24.h
#include yellowsmiley24.h
#endif

#define PIN 3 // This is the pin where the data is coming out (you don't have to worry about this)

const int button1          = 4;     // the number of the arcade button pins
const int button2          = 5;
const int button3          = 6;
const int button4          = 7;
const int brightnessSwitch = 8;

// variables will change:
int button1State           = 0;     // variable for reading the pushbutton status
int button2State           = 0;
int button3State           = 0;
int button4State           = 0;
int switchState            = 0;
int panelBrightness        = 0;



                                                                        // This stuff tells the board how the lights are arranged.
Adafruit_NeoMatrix matrix = Adafruit_NeoMatrix(20,                      // In our case, it starts at the top left,
                                               15,                      //   and the signal goes right, and zigzags the rest of the way.
                                               PIN,                     // It also tells it that it is 20 by 15 LEDs
                                               NEO_MATRIX_TOP + NEO_MATRIX_RIGHT + NEO_MATRIX_ROWS + NEO_MATRIX_ZIGZAG,
                                               NEO_GRB + NEO_KHZ800);

void setup() {
  pinMode(button1, INPUT);                                              // initialize the buttons as inputs:
  pinMode(button2, INPUT);
  pinMode(button3, INPUT);
  pinMode(button4, INPUT);

  pinMode(brightnessSwitch, INPUT);

  matrix.begin();
  matrix.setTextWrap(false);

  Serial.begin(9600);
  Serial.print("The LED Matrix has started. Default will be activated soon");
}

String panelText = buttonText1;                                         // This is what text gets fed to the panel

int x    = matrix.width();
int pass = 0;

void loop() {
  matrix.setBrightness(panelBrightness);                                // This sets the overall brightness. 255 is the highest, while 0 is the lowest

  button1State = digitalRead(button1);                                  // read the state of the buttons
  button2State = digitalRead(button2);
  button3State = digitalRead(button4);
  button4State = digitalRead(button4);

  switchState = digitalRead(brightnessSwitch);

  if (switchState == HIGH) { panelBrightness = switchLevel1; }          // Brightness Logic
  else                     { panelBrightness = switchLevel2; }


  // if-then statements
  if (button1State == HIGH) {                                           // BUTTON 1 CODE START
    static int i = 0;
    i++;
    for(int y = 0; y < 15; y++)
      for(int x = 0; x < 20; x++)
        if(y & 1)
          matrix.setPixelColor(19 - x + y * 20, matrix.gamma32(matrix.ColorHSV((x + y) * 256 * colorsOnscreen1 + i * 128 * 2)));
        else
          matrix.setPixelColor(     x + y * 20, matrix.gamma32(matrix.ColorHSV((x + y) * 256 * colorsOnscreen1 + i * 128 * 2)));

    matrix.setTextColor(matrix.Color(255, 255, 255));                   // This determines the text color.
    matrix.setCursor(-((millis() / 40) & 127), 4);                      //     If you want to set a text color, search in google "Color Picker"
                                                                        //     and use the RGB values in place of the numbers in (a,a,a)
    matrix.print(buttonText1);
    matrix.show();
  }                                                                     // BUTTON 1 CODE END

  else {
    if (button2State == HIGH) {                                         // BUTTON 2 CODE START
                                                                        //    PUT WHAT HAPPENS FOR BUTTON 2 HERE
    }                                                                   // BUTTON 2 CODE END
    else {
      if (button3State == HIGH) {                                       // BUTTON CODE 3 START
        static int i = 0;
        i++;
        for(int y = 0; y < 15; y++)
          for(int x = 0; x < 20; x++)
            if(y & 1)
              matrix.setPixelColor(19 - x + y * 20, matrix.gamma32(matrix.ColorHSV((x - y) * 200 * colorsOnscreen3 + i * 128 * 2)));
            else
              matrix.setPixelColor(     x + y * 20, matrix.gamma32(matrix.ColorHSV((x - y) * 256 * colorsOnscreen3 + i * 128 * 2)));

        matrix.setTextColor(matrix.Color(255, 255, 255));
        matrix.setCursor(-((millis() / 40) & 127), 4);

        matrix.print(buttonText3);
        matrix.show();
      }                                                                 // BUTTON 3 CODE END
      else {
        if (button4State == HIGH){                                      // BUTTON 4 CODE START
                                                                        //    PUT WHAT HAPPENS FOR BUTTON 4 HERE
        }                                                               // BUTTON 4 CODE END
        else {                                                          // WHAT HAPPENS UNTIL A BUTTON IS PRESSED


          static int i = 0;
          i++;
//        matrix.fillScreen(0);
          for(int y = 0; y < 15; y++)
            for(int x = 0; x < 20; x++)
              if(y & 1)
                matrix.setPixelColor(19 - x + y * 20, matrix.gamma32(matrix.ColorHSV((x + y) * 256 * colorsOnscreenDefault + i * 128 * 2)));
              else
                matrix.setPixelColor(     x + y * 20, matrix.gamma32(matrix.ColorHSV((x + y) * 256 * colorsOnscreenDefault + i * 128 * 2)));

          matrix.setTextColor(matrix.Color(255, 255, 255));
          matrix.setCursor(-((millis() / 70) & 127), 4);

          matrix.println(defaultText);
          matrix.show();
        }
      }
    }
  }
}

    //   HEY! LOOK UP HERE! I know it looks confusing, but don't worry, I'll help you! I'm Clippy!
    //    _________________
    //   < I can help you! >
    //    -----------------
    //    \
    //     \
    //        __
    //       /  \
    //       |  |
    //       @  @
    //       |  |
    //       || |/
    //       || ||
    //       |\_/|
    //       \___/

    // As you know, there are 4 buttons. When they are pressed, they display something different. We can make them display text as well.
    // Below are VARIABLES, which control what text is displayed when buttons are pressed. Put what you want them to display between the
    // quotation marks. If you don't want anything in a button, just put a space inbetween them.

                                                  // Note: only button 1 and 3 can display text, so lets only put text in those :)
    String buttonText1 = " ";                     // Again, put what you want button 1 to display in text
//  String buttonText2 = " ";
    String buttonText3 = " ";
//  String buttonText4 = " ";

    String defaultText = "   Text for the panel"; // This is what will show up when you first start it up



    int switchLevel1 =  10;                       // Here we can adjust what the brightness of the panel is.
    int switchLevel2 = 200;                       // We use a switch to do this. You can use values from 0 (lowest) to 255 (highest)

                                                  // Here we can control how many colors are on the backgrounds at one time.
                                                  // We can customize this to get some variety in our displays.
    int colorsOnscreen1 =  5;                     // For button 1
//  int colorsOnscreen2 =  3;
    int colorsOnscreen3 = 10;                     // For button 3
//  int colorsOnscreen4 =  5;

    int colorsOnscreenDefault = 3;                // For when you start it up

    int lastButton = 0;                           // Last button pressed stuff, gets fed to buttons


    //----------------------------------------------------------------You Probably Don't Have To Worry About The Rest----------------------------------------------------------------

    //This stuff you don't have to worry about, its for the board

    #include <Adafruit_NeoPixel.h>
    #include <Adafruit_GFX.h>
    #include <Adafruit_SPITFT.h>
    #include <Adafruit_SPITFT_Macros.h>
    #include <gfxfont.h>
    #include <Adafruit_NeoMatrix.h>
    #include <gamma.h>
    #include "RGB.h"
    #ifndef PSTR
      #define PSTR
      #include smileytongue24.h
      #include yellowsmiley24.h
    #endif

    #define PIN 3 // This is the pin where the data is coming out (you don't have to worry about this)

    const int button1          = 4;     // the number of the arcade button pins
    const int button2          = 5;
    const int button3          = 6;
    const int button4          = 7;
    const int brightnessSwitch = 8;

    // variables will change:
    int button1State           = 0;     // variable for reading the pushbutton status
    int button2State           = 0;
    int button3State           = 0;
    int button4State           = 0;
    int switchState            = 0;
    int panelBrightness        = 0;



                                                                        // This stuff tells the board how the lights are arranged.
    Adafruit_NeoMatrix matrix = Adafruit_NeoMatrix(20,                  // In our case, it starts at the top left,
                                                   15,                  //   and the signal goes right, and zigzags the rest of the way.
                                                   PIN,                 // It also tells it that it is 20 by 15 LEDs
                                                   NEO_MATRIX_TOP + NEO_MATRIX_RIGHT + NEO_MATRIX_ROWS + NEO_MATRIX_ZIGZAG,
                                                   NEO_GRB + NEO_KHZ800);

    void setup() {
      pinMode(button1, INPUT);                                          // initialize the buttons as inputs:
      pinMode(button2, INPUT);
      pinMode(button3, INPUT);
      pinMode(button4, INPUT);

      pinMode(brightnessSwitch, INPUT);

      matrix.begin();
      matrix.setTextWrap(false);

      Serial.begin(9600);
      Serial.print("The LED Matrix has started. Default will be activated soon");
    }

    String panelText = buttonText1;                                     // This is what text gets fed to the panel

    int x    = matrix.width();
    int pass = 0;

    void loop() {
      matrix.setBrightness(panelBrightness);                            // This sets the overall brightness. 255 is the highest, while 0 is the lowest

      button1State = digitalRead(button1);                              // read the state of the buttons
      button2State = digitalRead(button2);
      button3State = digitalRead(button4);
      button4State = digitalRead(button4);

      switchState = digitalRead(brightnessSwitch);

      if (switchState == HIGH) { panelBrightness = switchLevel1; }      // Brightness Logic
      else                     { panelBrightness = switchLevel2; }


      // if-then statements
      if (button1State == HIGH) {                                       // BUTTON 1 CODE START

        static int i = 0;
        i++;
        for (int y = 0; y < 15; y++) {
          for (int x = 0; x < 20; x++) {
            if (y & 1) {
              matrix.setPixelColor(19 - x + y * 20, matrix.gamma32(matrix.ColorHSV((x + y) * 256 * colorsOnscreen1 + i * 128 * 2)));
            }
            else {
              matrix.setPixelColor(     x + y * 20, matrix.gamma32(matrix.ColorHSV((x + y) * 256 * colorsOnscreen1 + i * 128 * 2)));
            }
          }
        }

        matrix.setTextColor(matrix.Color(255, 255, 255));               // This determines the text color.
        matrix.setCursor(-((millis() / 40) & 127), 4);                  //     If you want to set a text color, search in google "Color Picker"
                                                                        //     and use the RGB values in place of the numbers in matrix.Color(r,g,b)
        matrix.print(buttonText1);
        matrix.show();
      }                                                                 // BUTTON 1 CODE END

      else if (button2State == HIGH) {                                  // BUTTON 2 CODE START
                                                                        //    PUT WHAT HAPPENS FOR BUTTON 2 HERE
      }                                                                 // BUTTON 2 CODE END

      else if (button3State == HIGH) {                                  // BUTTON CODE 3 START

        static int i = 0;
        i++;
        for (int y = 0; y < 15; y++) {
          for (int x = 0; x < 20; x++) {
            if (y & 1) {
              matrix.setPixelColor(19 - x + y * 20, matrix.gamma32(matrix.ColorHSV((x - y) * 200 * colorsOnscreen3 + i * 128 * 2)));
            }
            else {
              matrix.setPixelColor(     x + y * 20, matrix.gamma32(matrix.ColorHSV((x - y) * 256 * colorsOnscreen3 + i * 128 * 2)));
            } 
          } 
        } 

        matrix.setTextColor(matrix.Color(255, 255, 255));
        matrix.setCursor(-((millis() / 40) & 127), 4);

        matrix.print(buttonText3);
        matrix.show();
      }                                                                 // BUTTON 3 CODE END

      else if (button4State == HIGH) {                                  // BUTTON 4 CODE START
                                                                        //    PUT WHAT HAPPENS FOR BUTTON 4 HERE
      }                                                                 // BUTTON 4 CODE END

      else {                                                            // WHAT HAPPENS UNTIL A BUTTON IS PRESSED

        static int i = 0;
        i++;
//      matrix.fillScreen(0);
        for (int y = 0; y < 15; y++) {
          for (int x = 0; x < 20; x++) {
            if (y & 1) {
              matrix.setPixelColor(19 - x + y * 20, matrix.gamma32(matrix.ColorHSV((x + y) * 256 * colorsOnscreenDefault + i * 128 * 2)));
            }
            else {
              matrix.setPixelColor(     x + y * 20, matrix.gamma32(matrix.ColorHSV((x + y) * 256 * colorsOnscreenDefault + i * 128 * 2)));
            }
          }
        }

        matrix.setTextColor(matrix.Color(255, 255, 255));
        matrix.setCursor(-((millis() / 70) & 127), 4);

        matrix.println(defaultText);
        matrix.show();
      }
    }
| improve this answer | |
  • Thank you for cleaning up my code! You're right, it does make it easier to understand. Again, thanks for your help! – Micah Wagoner Jan 1 at 19:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.