Max7219 8 Digit 7 Segment Interface dengan Arduino Uno

Overview

Seperti yang kita ketahui 7 Segment terdiri dari 7 LED, setiap LED terdapat dua kaki yaitu Anoda dan Cathoda.

Terdapat 2 type 7 Segment, Common Cathode(CC) dan Common Anode(CA). seperti gambar dibawah ini

Ada beberapa cara untuk menghidupkan 7 Segment:

Agar mudah dalam wiring, maka kita bisa menggunakan Max7219. dengan Max7219 kita bisa mengcascadekan 8 Max7219 (total 64 7Segment) dengan hanya 5 kabel (SPI)

Schematic


Program/source code

//We always have to include the library
#include "LedControl.h"

/*
 Now we need a LedControl to work with.
 ***** These pin numbers will probably not work with your hardware *****
 pin 12 is connected to the DataIn 
 pin 11 is connected to the CLK 
 pin 10 is connected to LOAD 
 We have only a single MAX72XX.
 */
#define Buzzer 8  // Pin 8 connected to Buzzer +positive pin
LedControl lc=LedControl(12,11,10,1);

/* we always wait a bit between updates of the display */
unsigned long delaytime=1000;
long int countnumber=24001000 ; // Countdown timer start value HH:MM:SSSS
int BuzzTrigger=0;  // Variable to store buzzer trigger value
// Variables to store individual numbers
int  firstnum=0;
int  secondnum=0;
int  thirdnum=0;
int  fournum=0;
int  fivenum=0;
int  sixnum=0;
int  sevennum=0;
int  eightnum=0;

void setup() {
  /*
   The MAX72XX is in power-saving mode on startup,
   we have to do a wakeup call
   */
  lc.shutdown(0,false);
  /* Set the brightness to a medium values */
  lc.setIntensity(0,8);
  /* and clear the display */
  lc.clearDisplay(0);
}


/*
 This method will display the characters for the
 word "Arduino" one after the other on digit 0. 
 */


/*
  This method will scroll all the hexa-decimal
 numbers and letters on the display. You will need at least
 four 7-Segment digits. otherwise it won't really look that good.
 */



void loop() { 
lc.setChar(0,7,'B',false);
delay(delaytime);
lc.setChar(0,6,'a',false);
delay(delaytime);
lc.setChar(0,5,'C',false);
delay(delaytime);
lc.setChar(0,4,'a',false);
delay(delaytime);
lc.setChar(0,3,'L',false);
delay(delaytime);
lc.setChar(0,2,'a',false);
delay(delaytime);
lc.setChar(0,1,'h',false);
delay(delaytime);
lc.setChar(0,0,'_',false);
delay(delaytime);
lc.clearDisplay(0);
}
void writeArduinoOn7Segment() {
  lc.setChar(0,7,'a',false);
  delay(delaytime);
  lc.setRow(0,6,0x05);
  delay(delaytime);
  lc.setChar(0,5,'d',false);
  delay(delaytime);
  lc.setRow(0,4,0x1c);
  delay(delaytime);
  lc.setRow(0,3,B00010000);
  delay(delaytime);
  lc.setRow(0,2,0x15);
  delay(delaytime);
  lc.setRow(0,1,0x1D);
  delay(delaytime);
  lc.setChar(0,0,'_',false);
  delay(10*delaytime);
  lc.clearDisplay(0);
}

Demonstration

Wassalam

Leave a Reply

Your email address will not be published. Required fields are marked *