0% found this document useful (0 votes)
156 views5 pages

ATtiny85 Microcontroller Interface With MAX7219 Dot Matrix - Anas Kuzechie Projects

This document describes interfacing an ATtiny85 microcontroller with a MAX7219 dot matrix display. It includes code to display scrolling numeric countdown from 00 to 99 on the dot matrix using the ATtiny85 and MAX7219. The code initializes the dot matrix display, defines digit images as arrays, and uses interrupts to trigger counting. It then continuously displays the digits, incrementing the indexes and clearing in between to create a scrolling numeric display.

Uploaded by

rogeriokta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
156 views5 pages

ATtiny85 Microcontroller Interface With MAX7219 Dot Matrix - Anas Kuzechie Projects

This document describes interfacing an ATtiny85 microcontroller with a MAX7219 dot matrix display. It includes code to display scrolling numeric countdown from 00 to 99 on the dot matrix using the ATtiny85 and MAX7219. The code initializes the dot matrix display, defines digit images as arrays, and uses interrupts to trigger counting. It then continuously displays the digits, incrementing the indexes and clearing in between to create a scrolling numeric display.

Uploaded by

rogeriokta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

9th June 2021 ATtiny85 Microcontroller Interface with MAX7219 Dot Matrix

[https://1.bp.blogspot.com/-GrLPWyQ-
Atk/YME9aViXh9I/AAAAAAAAAxY/zedU0pGz4c0oUdsQpR4ePJV4Gkpj2fckwCLcBGAsYHQ/s960/MAX72xx%2BDot%2BMatrix
%2B%2528Tiny85%2529%2B2.jpg]

[https://1.bp.blogspot.com/-GqBdtWubMII/YME9j_FZmQI/AAAAAAAAAxc/1NlYxa1SosUkGP7uXgmEum-
6b4DaUh1bwCLcBGAsYHQ/s960/MAX72xx%2BDot%2BMatrix%2B%2528Tiny85%2529.jpg]
[https://1.bp.blogspot.com/-
xGGhEJZHwVQ/YMJeYZivlsI/AAAAAAAAAx4/pBQgvKk5vhULf3f39q0PD9wpnnM9T3gOACLcBGAsYHQ/s960/ATtiny85%2BInt
erface%2Bwith%2BMAX72xx%2BDot%2BMatrix.jpg]

NOTE: Since the video was uploaded to YouTube, a slight modification was done to the sketch to enable the count
from 00 to 99 (see video and modified sketch below).

//----------------------------------------------
//ATtiny85 Control of MAX7219 Dot MAtrix Display
//----------------------------------------------
#include <LedControl.h>
//----------------------------------------------
#define DIN   0
#define CS    1
#define CLK   3
LedControl disp=LedControl(DIN, CLK, CS, 4);
//--------------------------------------------------------------------------------
const byte digits[][8] = {
{B00010000,B00110000,B00010000,B00010000,B00010000,B00010000,B00010000,B00111000},
{B00111000,B01000100,B00000100,B00000100,B00001000,B00010000,B00100000,B01111100},
{B00111000,B01000100,B00000100,B00011000,B00000100,B00000100,B01000100,B00111000},
{B00000100,B00001100,B00010100,B00100100,B01000100,B01111100,B00000100,B00000100},
{B01111100,B01000000,B01000000,B01111000,B00000100,B00000100,B01000100,B00111000},
{B00111000,B01000100,B01000000,B01111000,B01000100,B01000100,B01000100,B00111000},
{B01111100,B00000100,B00000100,B00001000,B00010000,B00100000,B00100000,B00100000},
{B00111000,B01000100,B01000100,B00111000,B01000100,B01000100,B01000100,B00111000},
{B00111000,B01000100,B01000100,B01000100,B00111100,B00000100,B01000100,B00111000},
{B00111000,B01000100,B01000100,B01000100,B01000100,B01000100,B01000100,B00111000}};
//--------------------------------------------------------------------------------
const int digitLength = sizeof(digits)/8;
int digit1_index, digit2_index; bool startCount;
//================================================================================
void setup()

  for(int k=0; k<4; k++)
  {
    disp.shutdown(k, false);
    disp.setIntensity(k, 8);
    disp.clearDisplay(k);
  }
  //----------------------------------
  attachInterrupt(0,ISR_count,RISING);
}
//================================================================================
void ISR_count()
{
  startCount = !startCount;
}
//================================================================================
void loop()
{
  startCount = false; digit1_index = 0; digit2_index = 0;
  //-----------------------------------------------------
  tiny85Disp();
  //-----------------------------------------------------
  if(startCount == true)
  {
    clearDisp();
    digitCount();
  }
}
//================================================================================
void digitCount()
{
  //display digit 0 at address 1
  disp.setRow(1,0,B00111000);
  for(int counter=1; counter<7; counter++) disp.setRow(1,counter,B01000100);
  disp.setRow(1,7,B00111000);
  //------------------------------------------------------------------------
  while(1)
  {
    if(startCount == false)
    {
      disp.clearDisplay(1); break;
    }
    //---------------------------------------------------
    displayDigit1(digits[digit1_index]);
    delay(250);
    disp.clearDisplay(2);
    //---------------------------------------------------
    if(++digit1_index >= digitLength) digit1_index = 0;
    if(digit1_index >= digitLength-1)
    {
      displayDigit2(digits[digit2_index]);
      if(++digit2_index >= digitLength) digit2_index = 0;
    }
  }
}
//================================================================================
void displayDigit1(const byte* image)
{
  for(int i = 0; i < 8; i++)
  {
    for(int j = 0; j < 8; j++) disp.setLed(2, i, j, bitRead(image[i], 7 - j));
  }
}
//================================================================================
void displayDigit2(const byte* image)
{
  for(int i = 0; i < 8; i++)
  {
    for(int j = 0; j < 8; j++) disp.setLed(1, i, j, bitRead(image[i], 7 - j));
  }
}
//================================================================================
void clearDisp()
{
  for(int k=0; k<4; k++) disp.clearDisplay(k);
}
//================================================================================
void tiny85Disp()
{
  //T
  disp.setRow(0,1,B01111100);
  disp.setColumn(0,3,B01111110);
  //i
  disp.setColumn(0,7,B01011110);
  //n
  disp.setRow(1,3,B01111000);
  disp.setColumn(1,1,B00011110);
  disp.setColumn(1,4,B00011110);
  //y
  disp.setColumn(1,6,B01110010);
  disp.setColumn(1,7,B00010010);
  disp.setColumn(2,0,B00010010);
  disp.setColumn(2,1,B01111110);
  //8
  disp.setColumn(2,4,B01101110);
  disp.setColumn(2,5,B10010001);
  disp.setColumn(2,6,B10010001);
  disp.setColumn(2,7,B10010001);
  disp.setColumn(3,0,B01101110);
  //5
  disp.setColumn(3,2,B11110001);
  disp.setColumn(3,3,B10010001);
  disp.setColumn(3,4,B10010001);
  disp.setColumn(3,5,B10010001);
  disp.setColumn(3,6,B10001110);
}

Posted 9th June 2021 by Anas Kuzechie Projects

0
Add a comment

You might also like