Quantcast
Channel: Arduino Forum - Latest topics
Viewing all articles
Browse latest Browse all 16085

How to control 2 LED matrix (MAX7219) using potentiometer

$
0
0

Hello all, I'm new to Arduino and coding. I am trying to light up the LEDs of two 8x8 matrix using a potentiometer. Matrix1 will light up when the pot value ranges from 0 to 500, and another matrix will glow when the pot value ranges from 500 to 1023. I have tried with one LED matrix and need some guidance on connecting the second matrix and making it working.

Here I have given the code for single LED matrix
Code:

#include <LedControl.h>
int DIN = 11;
int CS =  10;
int CLK = 13;
LedControl lc=LedControl(DIN,CLK,CS,2);

void setup(){
 lc.shutdown(0,false); 
 lc.setIntensity(0,50);
 lc.clearDisplay(0);
}
void printByte(byte character []){
  int i = 0;
  for(i=0;i<8;i++){
    lc.setRow(0,i,character[i]);
  }
}

void loop(){ 
  byte cero[8] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
  int value = analogRead(A0); // read of potentiometer value
  int scale = map(value, 500, 1000, 0, 13); // map function to get brightness

  for (int i=0;i<scale;i++){
    cero[i] = 0xff;
  }

  printByte(cero);

  delay(100);
}

2 posts - 2 participants

Read full topic


Viewing all articles
Browse latest Browse all 16085

Latest Images

Trending Articles



Latest Images