How to connect 2 Digit 7 Segment and control with an Arduino using the M...



7 Segment Display

A 7 segment display is basically just a couple of  regular LEDs behind a stencil. Each led lights up a particular segment


diagram 2 digit 7 Segment 

MAX7219

MAX7219 is LED driver available it's probably the easiest to use and can control manu LEDs using only one chip


schematic diagram

This schematic diagram  connect some capacitors to filter out the noise from the power supply,but this is optional ,You can built it without


Arduino Sketch


#include "LedControl.h"  // Library used for communcation with 7 segment

LedControl lc=LedControl(12,11,10,1);  //  (DIN, CLK, LOAD, number of Max7219 chips)

// Variable to hold current scores
int counter=0;

// Variables to split whole number into single digits
int rightdigit;
int leftdigit;

void setup() {
  
  lc.shutdown(0,false);  // Wake up MAX7219
  lc.setIntensity(0,2);  // Set brightness to medium
  lc.clearDisplay(0);  // Clear all displays connected to MAX7219 chip #

// Put zeros on both displays at startup
  
  lc.setDigit(0,0,0,false);  // (Max7219 chip #, Digit, value, DP on or off)
  lc.setDigit(0,1,0,false);
  
}


void loop() { 
  
  counter++;
  if( counter > 100) counter = 0;

    rightdigit=counter%10;
    leftdigit=counter%100/10;

    // Display extracted digits on the display
    lc.setDigit(0,0,rightdigit,true);
    lc.setDigit(0,1,leftdigit,false);

    delay(100);
  
}

ความคิดเห็น