Shahariar
Published © GPL3+

Dot Canvas Badge: Art on Matrix Display

It's a dot matrix art, fun badge to draw 8x8 images on a RGY tri-color dot matrix display.

IntermediateFull instructions provided10 hours557

Things used in this project

Hardware components

SparkFun Dot Matrix Dual Color
×1
Atmeg32A 40 PIN DIP
×1
SparkFun Tactile Button
×4
Capacitor 1 µF
Capacitor 1 µF
×3
Resistor 100 ohm
Resistor 100 ohm
×24
Male-Header 36 Position 1 Row- Long (0.1")
Male-Header 36 Position 1 Row- Long (0.1")
×1
AA Batteries
AA Batteries
×4
4xAA battery holder
4xAA battery holder
×1
Resistor 0.05 ohm
Resistor 0.05 ohm
×6
Resistor 0.05 ohm
Resistor 0.05 ohm
×6
Capacitor 100 µF
Capacitor 100 µF
×1
Capacitor 100 µF
Capacitor 100 µF
×1
Veroboard (generic)
×1

Story

Read more

Schematics

Sch

https://easyeda.com/suntop/dot-badge-final

Code

Dot Art

C/C++
tri color art on 8x8 matrix ver 1.0.0
#include <avr/sleep.h>
#include <avr/wdt.h>
#include <avr/interrupt.h>

volatile int nth_dot = 1;
volatile boolean dot_select = 1;

int old_nth_dot = 1;
int end_of_display = 0;
boolean painting_cursor = 1;
// brightness range 1 to 1000
int brightness=200; // high brightness increases flickering 

volatile boolean *dotpointer;
volatile int color_selector=1;

// 0 for dot lED on , 1 for dot LED off
// following 3 array will hold R,G,Y pixel info

volatile boolean canvasR[64] =
{ 

  1,1,1,1,1,1,1,1,
  1,1,1,1,1,1,1,1,
  1,1,1,1,1,1,1,1,
  1,1,1,1,1,1,1,1,
  1,1,1,1,1,1,1,1,
  1,1,1,1,1,1,1,1,
  1,1,1,1,1,1,1,1,  
  1,1,1,1,1,1,1,1,  

};  

volatile boolean canvasG[64] =
{ 

  1,1,1,1,1,1,1,1,
  1,1,1,1,1,1,1,1,
  1,1,1,1,1,1,1,1,
  1,1,1,1,1,1,1,1,
  1,1,1,1,1,1,1,1,
  1,1,1,1,1,1,1,1,
  1,1,1,1,1,1,1,1,  
  1,1,1,1,1,1,1,1,  

};  

volatile boolean canvasY[64] =
{ 

  1,1,1,1,1,1,1,1,
  1,1,1,1,1,1,1,1,
  1,1,1,1,1,1,1,1,
  1,1,1,1,1,1,1,1,
  1,1,1,1,1,1,1,1,
  1,1,1,1,1,1,1,1,
  1,1,1,1,1,1,1,1,  
  1,1,1,1,1,1,1,1,  

};  



void setup() 
{

  io_init();
  sw_interrupt_init();
  display_init();
  display_off();

  // ROW Active HIGH, COLUMN Active LOW


}

void loop() 

{

  // refrest screen
  for(int i=0;i<10;i++)
  {
    dotpointer = &canvasR[0];
    display_pageR(dotpointer);
    display_pageR(dotpointer);
 
    dotpointer = &canvasG[0];
    display_pageG(dotpointer);
    display_pageG(dotpointer);
    
    dotpointer = &canvasY[0];
    display_pageY(dotpointer);
    display_pageY(dotpointer);
    
    
  }

  // update canvas with toggling painting cursor position
  if (dot_select == 1)
  {
    if (old_nth_dot == nth_dot & end_of_display == 0)
    {
      painting_cursor = ! painting_cursor;
      if (color_selector==1)
      {
      canvasR[nth_dot-1] = painting_cursor; 
      }
     if (color_selector==2)
      {
      canvasG[nth_dot-1] = painting_cursor; 
      } 
     if (color_selector==3)
      {
      canvasY[nth_dot-1] = painting_cursor; 
      } 
       
    }
  }
  // set a dot in current pos and move painting cursor
  if (dot_select == 0)
  {
    if (color_selector==1)
    {
    canvasR[nth_dot-1] = dot_select;
    }
    
    if (color_selector==2)
    {
    canvasG[nth_dot-1] = dot_select;
    }
    if (color_selector==3)
    {
    canvasY[nth_dot-1] = dot_select;
    }
    
    
    dot_select=1;
    nth_dot++;
    old_nth_dot = nth_dot;
  }



}

////////////// Void Loop ends here ///////////////
// Interrupt, Display Drive etc functions below //



// D2 for INT 2 RED PUSH SWITCH
// D3 for PWM BUZZER Drive
// D10 INT 0 GREEN PUSH SWITCH
// D11 INT 1 BLUE PUSH SWITCH

// D4 spare line, not used


// initialize buzzer and push switch
void io_init (void)
{


// pinMode(4,OUTPUT) Spare outout line 
 pinMode(3,OUTPUT);
 pinMode(2,INPUT_PULLUP);
 pinMode(10,INPUT_PULLUP);
 pinMode(11,INPUT_PULLUP);
 
}

// D10 INT 0 GREEN PUSH SWITCH
// D11 INT 1 BLUE PUSH SWITCH
// D2  INT 2 RED PUSH SWITCH

/*
http://ww1.microchip.com/downloads/en/DeviceDoc/Atmel-8155-8-bit-Microcontroller-AVR-ATmega32A_Datasheet.pdf

ATMEGA32A Datasheet page 69:

"""" The External Interrupts are triggered by the INT0, INT1, and INT2 pins. Observe that, if 
enabled,the interrupts will trigger even if the INT0:2 pins are configured as outputs. This 
feature provides a way of generating a software interrupt. The external interrupts can be 
triggered by a falling or rising edge or a low level (INT2 is only an edge triggered interrupt). 
This is set up as indicated in the specification for the MCU Control Register – MCUCR – and MCU 
Control and Status Register – MCUCSR. When the external interrupt is enabled and is configured 
as level triggered (only INT0/INT1), the interrupt will trigger as long as the pin is held low. 

Note that  recognition of falling or rising edge interrupts on INT0 and INT1 requires the presence
of an  I/O clock, described in “Clock Systems and their Distribution” on page 25. LOW level 
interrupts  on INT0/INT1 and the EDGE (FALLING) interrupt on INT2 are detected asynchronously """"


*/

// function to enable interrupts on 3 input switches //
void sw_interrupt_init(void)
{
  
attachInterrupt(0, ISR_SW_GREEN,LOW);
attachInterrupt(1, ISR_SW_BLUE,LOW);
//attachInterrupt(2, ISR_SW_RED,FALLING);// not working, done by register twiddling
GICR &= ~(1<<5);
MCUCSR &= ~(1<<6);
GICR |= (1<<5);

}


// ISR for Green switch //
void ISR_SW_GREEN()
{
  if (nth_dot<=64)
  {
   canvasR[nth_dot-1] = 1;
   canvasG[nth_dot-1] = 1;
   canvasY[nth_dot-1] = 1;
  nth_dot++;
  if (nth_dot>64)
  {end_of_display=1;}
  old_nth_dot = nth_dot;
  }
digitalWrite(3,1);
delay(5);
digitalWrite(3,0);
while(digitalRead(10)==0)
 {
  cli();
 }
 sei();

}

// ISR for Red switch //
ISR(INT2_vect)
{
  cli();  
dot_select = 0  ;
digitalWrite(3,1);
delay(5);
digitalWrite(3,0);
sei();
}


// ISR for Blue switch //
void ISR_SW_BLUE()
{
   canvasR[nth_dot-1] = 1;
   canvasG[nth_dot-1] = 1;
   canvasY[nth_dot-1] = 1;
 
   color_selector++;
   dot_select = 1  ;
   if (color_selector>3)
   {color_selector=1;}
 while(digitalRead(11)==0)
 {
  cli();
 }
 sei();
/*
/////// single color mode BLUE switch work as backspace ///////
  if (nth_dot>0)
  {
   canvasR[nth_dot-1] = 1;
   canvasG[nth_dot-1] = 1;
   canvasY[nth_dot-1] = 1;
 
   nth_dot--;
   if (nth_dot<=0)
    {nth_dot=1;}
   old_nth_dot = nth_dot;
  }
  
digitalWrite(3,1);
delay(5);
digitalWrite(3,0);
while(digitalRead(11)==0)
 {
  cli();
 }
 sei();
*/
}


///////////////////////////////////////////////
// enable 24 pins connected to Matrix display as Output
// for display driving


void display_init (void)
{
  pinMode(31, OUTPUT);
  pinMode(30, OUTPUT);// 
  pinMode(29, OUTPUT);
  pinMode(28, OUTPUT);
  pinMode(27, OUTPUT);//
  pinMode(26, OUTPUT);
  pinMode(25, OUTPUT);
  pinMode(24, OUTPUT);//
  pinMode(23, OUTPUT);
  pinMode(22, OUTPUT);
  pinMode(21, OUTPUT);//
  pinMode(20, OUTPUT);
  pinMode(19, OUTPUT);
  pinMode(18, OUTPUT);//
  pinMode(17, OUTPUT);
  pinMode(16, OUTPUT);
  pinMode(15, OUTPUT);//
  pinMode(14, OUTPUT);
  pinMode(13, OUTPUT);
  pinMode(12, OUTPUT);//
  pinMode(8, OUTPUT);
  pinMode(9, OUTPUT);
  pinMode(1, OUTPUT);
  pinMode(0, OUTPUT);//

}

// turn off all pixels/dots

void display_off(void)
{
  // Column RED  
  digitalWrite(31, HIGH);    // COL 1
  digitalWrite(28, HIGH);    // COL 2
  digitalWrite(16, HIGH);    // COL 3
  digitalWrite(14, HIGH);    // COL 4 
  digitalWrite(25, HIGH);    // COL 5
  digitalWrite(9,  HIGH);    // COL 6
  digitalWrite(22, HIGH);    // COL 7
  digitalWrite(19, HIGH);    // COL 8

  // Column GREEN

  digitalWrite(1,  HIGH);    // COL 1
  digitalWrite(29, HIGH);    // COL 2
  digitalWrite(17, HIGH);    // COL 3
  digitalWrite(13, HIGH);    // COL 4
  digitalWrite(26, HIGH);    // COL 5
  digitalWrite(8,  HIGH);    // COL 6
  digitalWrite(23, HIGH);    // COL 7
  digitalWrite(20, HIGH);    // COL 8

  // All Row 
  digitalWrite(0,  LOW);    // ROW 1
  digitalWrite(30, LOW);    // ROW 2
  digitalWrite(18, LOW);    // ROW 3
  digitalWrite(15, LOW);    // ROW 4
  digitalWrite(27, LOW);    // ROW 5
  digitalWrite(24, LOW);    // ROW 6
  digitalWrite(12, LOW);    // ROW 7
  digitalWrite(21, LOW);    // ROW 8

}

void display_clear(void)
{
  digitalWrite(0,  LOW);    // ROW 1
  digitalWrite(30, LOW);    // ROW 2
  digitalWrite(18, LOW);    // ROW 3
  digitalWrite(15, LOW);    // ROW 4
  digitalWrite(27, LOW);    // ROW 5
  digitalWrite(24, LOW);    // ROW 6
  digitalWrite(12, LOW);    // ROW 7
  digitalWrite(21, LOW);    // ROW 8

}

void display_onY(void)
{
  // Column RED
  digitalWrite(31, 0);    // COL 1
  digitalWrite(28, 0);    // COL 2
  digitalWrite(16, 0);    // COL 3
  digitalWrite(14, 0);    // COL 4 
  digitalWrite(25, 0);    // COL 5
  digitalWrite(9,  0);    // COL 6
  digitalWrite(22, 0);    // COL 7
  digitalWrite(19, 0);    // COL 8

  // Column GREEN 

  digitalWrite(1,  0);    // COL 1
  digitalWrite(29, 0);    // COL 2
  digitalWrite(17, 0);    // COL 3
  digitalWrite(13, 0);    // COL 4
  digitalWrite(26, 0);    // COL 5
  digitalWrite(8,  0);    // COL 6
  digitalWrite(23, 0);    // COL 7
  digitalWrite(20, 0);    // COL 8

  // All Row inactivation
  digitalWrite(0,  1);    // ROW 1
  digitalWrite(30, 1);    // ROW 2
  digitalWrite(18, 1);    // ROW 3
  digitalWrite(15, 1);    // ROW 4
  digitalWrite(27, 1);    // ROW 5
  digitalWrite(24, 1);    // ROW 6
  digitalWrite(12, 1);    // ROW 7
  digitalWrite(21, 1);    // ROW 8

}

void display_onR(void)
{
  // Column RED
  digitalWrite(31, 0);    // COL 1
  digitalWrite(28, 0);    // COL 2
  digitalWrite(16, 0);    // COL 3
  digitalWrite(14, 0);    // COL 4 
  digitalWrite(25, 0);    // COL 5
  digitalWrite(9,  0);    // COL 6
  digitalWrite(22, 0);    // COL 7
  digitalWrite(19, 0);    // COL 8

  // Column GREEN 

  digitalWrite(1,  1);    // COL 1
  digitalWrite(29, 1);    // COL 2
  digitalWrite(17, 1);    // COL 3
  digitalWrite(13, 1);    // COL 4
  digitalWrite(26, 1);    // COL 5
  digitalWrite(8,  1);    // COL 6
  digitalWrite(23, 1);    // COL 7
  digitalWrite(20, 1);    // COL 8

  // All Row inactivation
  digitalWrite(0,  1);    // ROW 1
  digitalWrite(30, 1);    // ROW 2
  digitalWrite(18, 1);    // ROW 3
  digitalWrite(15, 1);    // ROW 4
  digitalWrite(27, 1);    // ROW 5
  digitalWrite(24, 1);    // ROW 6
  digitalWrite(12, 1);    // ROW 7
  digitalWrite(21, 1);    // ROW 8

}

void display_onG(void)
{
  // Column RED
  digitalWrite(31, 1);    // COL 1
  digitalWrite(28, 1);    // COL 2
  digitalWrite(16, 1);    // COL 3
  digitalWrite(14, 1);    // COL 4 
  digitalWrite(25, 1);    // COL 5
  digitalWrite(9,  1);    // COL 6
  digitalWrite(22, 1);    // COL 7
  digitalWrite(19, 1);    // COL 8

  // Column GREEN 

  digitalWrite(1,  0);    // COL 1
  digitalWrite(29, 0);    // COL 2
  digitalWrite(17, 0);    // COL 3
  digitalWrite(13, 0);    // COL 4
  digitalWrite(26, 0);    // COL 5
  digitalWrite(8,  0);    // COL 6
  digitalWrite(23, 0);    // COL 7
  digitalWrite(20, 0);    // COL 8

  // All Row activation
  digitalWrite(0,  1);    // ROW 1
  digitalWrite(30, 1);    // ROW 2
  digitalWrite(18, 1);    // ROW 3
  digitalWrite(15, 1);    // ROW 4
  digitalWrite(27, 1);    // ROW 5
  digitalWrite(24, 1);    // ROW 6
  digitalWrite(12, 1);    // ROW 7
  digitalWrite(21, 1);    // ROW 8

}

// following function update 1 Red Row //

void display_lineR(int R,boolean C1,boolean C2,boolean C3,boolean C4,boolean C5,boolean C6,boolean C7,boolean C8)
{
  display_off();
  if (R==1)
  {
    digitalWrite(0,  1);    // ROW 1
    digitalWrite(30, 0);    // ROW 2
    digitalWrite(18, 0);    // ROW 3
    digitalWrite(15, 0);    // ROW 4
    digitalWrite(27, 0);    // ROW 5
    digitalWrite(24, 0);    // ROW 6
    digitalWrite(12, 0);    // ROW 7
    digitalWrite(21, 0);    // ROW 8
  }
  if (R==2)
  {
    digitalWrite(0,  0);    // ROW 1
    digitalWrite(30, 1);    // ROW 2
    digitalWrite(18, 0);    // ROW 3
    digitalWrite(15, 0);    // ROW 4
    digitalWrite(27, 0);    // ROW 5
    digitalWrite(24, 0);    // ROW 6
    digitalWrite(12, 0);    // ROW 7
    digitalWrite(21, 0);    // ROW 8
  }
  if (R==3)
  {
    digitalWrite(0,  0);    // ROW 1
    digitalWrite(30, 0);    // ROW 2
    digitalWrite(18, 1);    // ROW 3
    digitalWrite(15, 0);    // ROW 4
    digitalWrite(27, 0);    // ROW 5
    digitalWrite(24, 0);    // ROW 6
    digitalWrite(12, 0);    // ROW 7
    digitalWrite(21, 0);    // ROW 8
  }
  if (R==4)
  {
    digitalWrite(0,  0);    // ROW 1
    digitalWrite(30, 0);    // ROW 2
    digitalWrite(18, 0);    // ROW 3
    digitalWrite(15, 1);    // ROW 4
    digitalWrite(27, 0);    // ROW 5
    digitalWrite(24, 0);    // ROW 6
    digitalWrite(12, 0);    // ROW 7
    digitalWrite(21, 0);    // ROW 8
  }


  if (R==5)
  {
    digitalWrite(0,  0);    // ROW 1
    digitalWrite(30, 0);    // ROW 2
    digitalWrite(18, 0);    // ROW 3
    digitalWrite(15, 0);    // ROW 4
    digitalWrite(27, 1);    // ROW 5
    digitalWrite(24, 0);    // ROW 6
    digitalWrite(12, 0);    // ROW 7
    digitalWrite(21, 0);    // ROW 8
  }
  if (R==6)
  {
    digitalWrite(0,  0);    // ROW 1
    digitalWrite(30, 0);    // ROW 2
    digitalWrite(18, 0);    // ROW 3
    digitalWrite(15, 0);    // ROW 4
    digitalWrite(27, 0);    // ROW 5
    digitalWrite(24, 1);    // ROW 6
    digitalWrite(12, 0);    // ROW 7
    digitalWrite(21, 0);    // ROW 8
  }
  if (R==7)
  {
    digitalWrite(0,  0);    // ROW 1
    digitalWrite(30, 0);    // ROW 2
    digitalWrite(18, 0);    // ROW 3
    digitalWrite(15, 0);    // ROW 4
    digitalWrite(27, 0);    // ROW 5
    digitalWrite(24, 0);    // ROW 6
    digitalWrite(12, 1);    // ROW 7
    digitalWrite(21, 0);    // ROW 8
  }
  if (R==8)
  {
    digitalWrite(0,  0);    // ROW 1
    digitalWrite(30, 0);    // ROW 2
    digitalWrite(18, 0);    // ROW 3
    digitalWrite(15, 0);    // ROW 4
    digitalWrite(27, 0);    // ROW 5
    digitalWrite(24, 0);    // ROW 6
    digitalWrite(12, 0);    // ROW 7
    digitalWrite(21, 1);    // ROW 8
  }

  digitalWrite(31, C1);    // COL 1
  digitalWrite(28, C2);    // COL 2
  digitalWrite(16, C3);    // COL 3
  digitalWrite(14, C4);    // COL 4 
  digitalWrite(25, C5);    // COL 5
  digitalWrite(9,  C6);    // COL 6
  digitalWrite(22, C7);    // COL 7
  digitalWrite(19, C8);    // COL 8
  delayMicroseconds(brightness);

}

// following function update 1 Green Row //
void display_lineG(int R,boolean C1,boolean C2,boolean C3,boolean C4,boolean C5,boolean C6,boolean C7,boolean C8)
{
  display_off();
  if (R==1)
  {
    digitalWrite(0,  1);    // ROW 1
    digitalWrite(30, 0);    // ROW 2
    digitalWrite(18, 0);    // ROW 3
    digitalWrite(15, 0);    // ROW 4
    digitalWrite(27, 0);    // ROW 5
    digitalWrite(24, 0);    // ROW 6
    digitalWrite(12, 0);    // ROW 7
    digitalWrite(21, 0);    // ROW 8
  }
  if (R==2)
  {
    digitalWrite(0,  0);    // ROW 1
    digitalWrite(30, 1);    // ROW 2
    digitalWrite(18, 0);    // ROW 3
    digitalWrite(15, 0);    // ROW 4
    digitalWrite(27, 0);    // ROW 5
    digitalWrite(24, 0);    // ROW 6
    digitalWrite(12, 0);    // ROW 7
    digitalWrite(21, 0);    // ROW 8
  }
  if (R==3)
  {
    digitalWrite(0,  0);    // ROW 1
    digitalWrite(30, 0);    // ROW 2
    digitalWrite(18, 1);    // ROW 3
    digitalWrite(15, 0);    // ROW 4
    digitalWrite(27, 0);    // ROW 5
    digitalWrite(24, 0);    // ROW 6
    digitalWrite(12, 0);    // ROW 7
    digitalWrite(21, 0);    // ROW 8
  }
  if (R==4)
  {
    digitalWrite(0,  0);    // ROW 1
    digitalWrite(30, 0);    // ROW 2
    digitalWrite(18, 0);    // ROW 3
    digitalWrite(15, 1);    // ROW 4
    digitalWrite(27, 0);    // ROW 5
    digitalWrite(24, 0);    // ROW 6
    digitalWrite(12, 0);    // ROW 7
    digitalWrite(21, 0);    // ROW 8
  }


  if (R==5)
  {
    digitalWrite(0,  0);    // ROW 1
    digitalWrite(30, 0);    // ROW 2
    digitalWrite(18, 0);    // ROW 3
    digitalWrite(15, 0);    // ROW 4
    digitalWrite(27, 1);    // ROW 5
    digitalWrite(24, 0);    // ROW 6
    digitalWrite(12, 0);    // ROW 7
    digitalWrite(21, 0);    // ROW 8
  }
  if (R==6)
  {
    digitalWrite(0,  0);    // ROW 1
    digitalWrite(30, 0);    // ROW 2
    digitalWrite(18, 0);    // ROW 3
    digitalWrite(15, 0);    // ROW 4
    digitalWrite(27, 0);    // ROW 5
    digitalWrite(24, 1);    // ROW 6
    digitalWrite(12, 0);    // ROW 7
    digitalWrite(21, 0);    // ROW 8
  }
  if (R==7)
  {
    digitalWrite(0,  0);    // ROW 1
    digitalWrite(30, 0);    // ROW 2
    digitalWrite(18, 0);    // ROW 3
    digitalWrite(15, 0);    // ROW 4
    digitalWrite(27, 0);    // ROW 5
    digitalWrite(24, 0);    // ROW 6
    digitalWrite(12, 1);    // ROW 7
    digitalWrite(21, 0);    // ROW 8
  }
  if (R==8)
  {
    digitalWrite(0,  0);    // ROW 1
    digitalWrite(30, 0);    // ROW 2
    digitalWrite(18, 0);    // ROW 3
    digitalWrite(15, 0);    // ROW 4
    digitalWrite(27, 0);    // ROW 5
    digitalWrite(24, 0);    // ROW 6
    digitalWrite(12, 0);    // ROW 7
    digitalWrite(21, 1);    // ROW 8
  }

  digitalWrite(1,  C1);    // COL 1
  digitalWrite(29, C2);    // COL 2
  digitalWrite(17, C3);    // COL 3
  digitalWrite(13, C4);    // COL 4
  digitalWrite(26, C5);    // COL 5
  digitalWrite(8,  C6);    // COL 6
  digitalWrite(23, C7);    // COL 7
  digitalWrite(20, C8);    // COL 8
  delayMicroseconds(brightness);


}


// following function update 1 Yellow Row //
void display_lineY(int R,boolean C1,boolean C2,boolean C3,boolean C4,boolean C5,boolean C6,boolean C7,boolean C8)
{
  display_off();
  if (R==1)
  {
    digitalWrite(0,  1);    // ROW 1
    digitalWrite(30, 0);    // ROW 2
    digitalWrite(18, 0);    // ROW 3
    digitalWrite(15, 0);    // ROW 4
    digitalWrite(27, 0);    // ROW 5
    digitalWrite(24, 0);    // ROW 6
    digitalWrite(12, 0);    // ROW 7
    digitalWrite(21, 0);    // ROW 8
  }
  if (R==2)
  {
    digitalWrite(0,  0);    // ROW 1
    digitalWrite(30, 1);    // ROW 2
    digitalWrite(18, 0);    // ROW 3
    digitalWrite(15, 0);    // ROW 4
    digitalWrite(27, 0);    // ROW 5
    digitalWrite(24, 0);    // ROW 6
    digitalWrite(12, 0);    // ROW 7
    digitalWrite(21, 0);    // ROW 8
  }
  if (R==3)
  {
    digitalWrite(0,  0);    // ROW 1
    digitalWrite(30, 0);    // ROW 2
    digitalWrite(18, 1);    // ROW 3
    digitalWrite(15, 0);    // ROW 4
    digitalWrite(27, 0);    // ROW 5
    digitalWrite(24, 0);    // ROW 6
    digitalWrite(12, 0);    // ROW 7
    digitalWrite(21, 0);    // ROW 8
  }
  if (R==4)
  {
    digitalWrite(0,  0);    // ROW 1
    digitalWrite(30, 0);    // ROW 2
    digitalWrite(18, 0);    // ROW 3
    digitalWrite(15, 1);    // ROW 4
    digitalWrite(27, 0);    // ROW 5
    digitalWrite(24, 0);    // ROW 6
    digitalWrite(12, 0);    // ROW 7
    digitalWrite(21, 0);    // ROW 8
  }


  if (R==5)
  {
    digitalWrite(0,  0);    // ROW 1
    digitalWrite(30, 0);    // ROW 2
    digitalWrite(18, 0);    // ROW 3
    digitalWrite(15, 0);    // ROW 4
    digitalWrite(27, 1);    // ROW 5
    digitalWrite(24, 0);    // ROW 6
    digitalWrite(12, 0);    // ROW 7
    digitalWrite(21, 0);    // ROW 8
  }
  if (R==6)
  {
    digitalWrite(0,  0);    // ROW 1
    digitalWrite(30, 0);    // ROW 2
    digitalWrite(18, 0);    // ROW 3
    digitalWrite(15, 0);    // ROW 4
    digitalWrite(27, 0);    // ROW 5
    digitalWrite(24, 1);    // ROW 6
    digitalWrite(12, 0);    // ROW 7
    digitalWrite(21, 0);    // ROW 8
  }
  if (R==7)
  {
    digitalWrite(0,  0);    // ROW 1
    digitalWrite(30, 0);    // ROW 2
    digitalWrite(18, 0);    // ROW 3
    digitalWrite(15, 0);    // ROW 4
    digitalWrite(27, 0);    // ROW 5
    digitalWrite(24, 0);    // ROW 6
    digitalWrite(12, 1);    // ROW 7
    digitalWrite(21, 0);    // ROW 8
  }
  if (R==8)
  {
    digitalWrite(0,  0);    // ROW 1
    digitalWrite(30, 0);    // ROW 2
    digitalWrite(18, 0);    // ROW 3
    digitalWrite(15, 0);    // ROW 4
    digitalWrite(27, 0);    // ROW 5
    digitalWrite(24, 0);    // ROW 6
    digitalWrite(12, 0);    // ROW 7
    digitalWrite(21, 1);    // ROW 8
  }

  digitalWrite(1,  C1);    // COL 1
  digitalWrite(29, C2);    // COL 2
  digitalWrite(17, C3);    // COL 3
  digitalWrite(13, C4);    // COL 4
  digitalWrite(26, C5);    // COL 5
  digitalWrite(8,  C6);    // COL 6
  digitalWrite(23, C7);    // COL 7
  digitalWrite(20, C8);    // COL 8
  digitalWrite(31, C1);    // COL 1
  digitalWrite(28, C2);    // COL 2
  digitalWrite(16, C3);    // COL 3
  digitalWrite(14, C4);    // COL 4 
  digitalWrite(25, C5);    // COL 5
  digitalWrite(9,  C6);    // COL 6
  digitalWrite(22, C7);    // COL 7
  digitalWrite(19, C8);    // COL 8
  delayMicroseconds(brightness);

}

///////////////////////////////////////////////////////
// following function updates 1 Red frame //
void display_pageR(volatile boolean *dot)
{
  display_lineR(1,*(dot+0) ,*(dot+1) ,*(dot+2) ,*(dot+3) ,*(dot+4) ,*(dot+5) ,*(dot+6) ,*(dot+7) );
  display_lineR(2,*(dot+8) ,*(dot+9) ,*(dot+10),*(dot+11),*(dot+12),*(dot+13),*(dot+14),*(dot+15));
  display_lineR(3,*(dot+16),*(dot+17),*(dot+18),*(dot+19),*(dot+20),*(dot+21),*(dot+22),*(dot+23));
  display_lineR(4,*(dot+24),*(dot+25),*(dot+26),*(dot+27),*(dot+28),*(dot+29),*(dot+30),*(dot+31));
  display_lineR(5,*(dot+32),*(dot+33),*(dot+34),*(dot+35),*(dot+36),*(dot+37),*(dot+38),*(dot+39));
  display_lineR(6,*(dot+40),*(dot+41),*(dot+42),*(dot+43),*(dot+44),*(dot+45),*(dot+46),*(dot+47));
  display_lineR(7,*(dot+48),*(dot+49),*(dot+50),*(dot+51),*(dot+52),*(dot+53),*(dot+54),*(dot+55));
  display_lineR(8,*(dot+56),*(dot+57),*(dot+58),*(dot+59),*(dot+60),*(dot+61),*(dot+62),*(dot+63));

}

// following function updates 1 Green frame //
void display_pageG(volatile boolean *dot)
{
      display_lineG(1,*(dot+0) ,*(dot+1) ,*(dot+2) ,*(dot+3) ,*(dot+4) ,*(dot+5) ,*(dot+6) ,*(dot+7) );
      display_lineG(2,*(dot+8) ,*(dot+9) ,*(dot+10),*(dot+11),*(dot+12),*(dot+13),*(dot+14),*(dot+15));
      display_lineG(3,*(dot+16),*(dot+17),*(dot+18),*(dot+19),*(dot+20),*(dot+21),*(dot+22),*(dot+23));
      display_lineG(4,*(dot+24),*(dot+25),*(dot+26),*(dot+27),*(dot+28),*(dot+29),*(dot+30),*(dot+31));
      display_lineG(5,*(dot+32),*(dot+33),*(dot+34),*(dot+35),*(dot+36),*(dot+37),*(dot+38),*(dot+39));
      display_lineG(6,*(dot+40),*(dot+41),*(dot+42),*(dot+43),*(dot+44),*(dot+45),*(dot+46),*(dot+47));
      display_lineG(7,*(dot+48),*(dot+49),*(dot+50),*(dot+51),*(dot+52),*(dot+53),*(dot+54),*(dot+55));
      display_lineG(8,*(dot+56),*(dot+57),*(dot+58),*(dot+59),*(dot+60),*(dot+61),*(dot+62),*(dot+63));

}

// following function updates 1 Yellow frame //
void display_pageY(volatile boolean *dot)
{
  display_lineY(1,*(dot+0) ,*(dot+1) ,*(dot+2) ,*(dot+3) ,*(dot+4) ,*(dot+5) ,*(dot+6) ,*(dot+7) );
  display_lineY(2,*(dot+8) ,*(dot+9) ,*(dot+10),*(dot+11),*(dot+12),*(dot+13),*(dot+14),*(dot+15));
  display_lineY(3,*(dot+16),*(dot+17),*(dot+18),*(dot+19),*(dot+20),*(dot+21),*(dot+22),*(dot+23));
  display_lineY(4,*(dot+24),*(dot+25),*(dot+26),*(dot+27),*(dot+28),*(dot+29),*(dot+30),*(dot+31));
  display_lineY(5,*(dot+32),*(dot+33),*(dot+34),*(dot+35),*(dot+36),*(dot+37),*(dot+38),*(dot+39));
  display_lineY(6,*(dot+40),*(dot+41),*(dot+42),*(dot+43),*(dot+44),*(dot+45),*(dot+46),*(dot+47));
  display_lineY(7,*(dot+48),*(dot+49),*(dot+50),*(dot+51),*(dot+52),*(dot+53),*(dot+54),*(dot+55));
  display_lineY(8,*(dot+56),*(dot+57),*(dot+58),*(dot+59),*(dot+60),*(dot+61),*(dot+62),*(dot+63));

}

/////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////
//  Pre defined Icons  //

void happy_face (void)
{
    for (int i=0;i<50;i++)
    {
    display_lineR(1,1,1,0,0,0,0,1,1);
    delay(1);
    display_lineR(2,1,0,1,1,1,1,0,1);
    delay(1);
    display_lineR(3,0,1,1,1,1,1,1,0);
    delay(1);
    display_lineY(3,1,1,0,1,1,0,1,1);
    delay(1);
    display_lineR(4,0,1,1,1,1,1,1,0);
    delay(1);
    display_lineY(4,1,1,0,1,1,0,1,1);
    delay(1);
    display_lineR(5,0,1,1,1,1,1,1,0);
    delay(1);
    display_lineR(6,0,1,1,1,1,1,1,0);
    delay(1);
    display_lineG(6,1,1,0,0,0,0,1,1);
    delay(1);
    display_lineR(7,1,0,1,1,1,1,0,1);
    delay(1);
    display_lineR(8,1,1,0,0,0,0,1,1);
    delay(1);
    }

}

void whatever_face(void)
{
    for (int i =0;i<50;i++)
    {
    display_lineG(1,1,1,0,0,0,0,1,1);
    delay(1);
    display_lineG(2,1,0,1,1,1,1,0,1);
    delay(1);
    display_lineG(3,0,1,1,1,1,1,1,0);
    delay(1);
    display_lineY(3,1,1,0,1,1,0,1,1);
    delay(1);
    display_lineG(4,0,1,1,1,1,1,1,0);
    delay(1);
    display_lineY(4,1,1,1,0,0,1,1,1);
    delay(1);
    display_lineG(5,0,1,1,1,1,1,1,0);
    delay(1);
    display_lineG(6,0,1,1,1,1,1,1,0);
    delay(1);
    display_lineR(6,1,1,1,0,0,1,1,1);
    delay(1);
    display_lineG(7,1,0,1,1,1,1,0,1);
    delay(1);
    display_lineG(8,1,1,0,0,0,0,1,1);
    delay(1);
    }
}

///////////////////////////////////////////////////
//////////////////////////////////////////////////

Credits

Shahariar

Shahariar

55 projects • 184 followers
"What Kills a 'Great life' is a 'Good Life', which is Living a Life Inside While Loop"

Comments