#include "LedControl.h" 

LedControl lc=LedControl(/*DIN*/11,/*CLK*/13,/*CS*/10,/*number of displays*/1); // initialization of the display

void setup() {
  
  lc.shutdown(0,false); 
  lc.setIntensity(0,8); 
  lc.clearDisplay(0); 

  pinMode(A0, INPUT); // set pin A0 to be analog input for reading the potentiometer value
}

void loop() { // main loop

  int potentiometer_value = analogRead(A0); // read the potentiometer value from pin A0
  potentiometer_value = map(potentiometer_value, 0, 1023, 0, 32); // remap the value from 0-1023 to 0-32


  for(int row=0;row<8;row++) { // for every row
    for(int col=0;col<8;col++) { // for every column

      if ((col + (row * 8)) < potentiometer_value) { // if the current LED index is smaller than the potentiometer value...
        lc.setLed(0,row,col,true); // turn the LED on
      } else { // otherwise...
        lc.setLed(0,row,col,false); // turn the LED off
      }
    }
  }
}