Hardware components | ||||||
| × | 1 | ||||
| × | 1 | ||||
| × | 4 | ||||
| × | 3 | ||||
| × | 24 | ||||
| × | 1 | ||||
| × | 4 | ||||
| × | 1 | ||||
| × | 6 | ||||
| × | 6 | ||||
| × | 1 | ||||
| × | 1 | ||||
| × | 1 |
It is a fun badge for drawing staffs on a RGY (Red, Green, Yellow = Red + Green) tri-color dot matrix display.
Working Principle & Hardware DescriptionThere is no library, no extra 7219 matrix driver IC used here. LED dots are driven directly through 24 GPIOs pins with 100 ohms resistors in series with each of them. pins are toggling fast to drive the display. The display works by toggling up to 8 LEDs of each line in one color, in case of yellow, both red and green LEDs in a dot glows.
The CPU speed is 8 MHz, clocked from internal oscillator. Switches are Interrupt driven with INT0, INT1, INT2 pins of ATmega32A and hardware debounced with 1 uF capacitors. There is also a restart button to erase current image.
4 AA batteries are placed in a 4 AA battery holder in series with a diode (to reduce voltage below absolute max) which yields 5.95 volts on fresh batteries. Current draw around 12-24 mA.
The buzzer makes click sound with every press to confirm user about input received.
BuildThe badge is built around Atmega32A mcu on a protoboard.
- 24 GPIOs for the Dot Matrix Display
- 3 Inputs (+reset) for Push Buttons
- 1 Output for Buzzer
- 4 SPI I/Os for Arduino as ISP
The yellow back cover is a plastic pencil box part which provides support for the thing. All electrical connections are made with solder and physical connections with hot glue!
Yellow Button: Clear Display (Reset)
Green Button: Move the blinking dot to next position ( right to current position)
Red Button: Set a dot with it's glowing color to it's current position
Blue Button: Shuffle color of the dot in R-G-Y sequence in current position
Power: 4x AA battery with diodes in series (almost 6 volts)
After few minutes of inactivity, device enters sleep mode to conserve power while image retains on RAM as long as reset is not pressed.
Voltage: From 6 volts down to 2 volts (RED only).
Glowing Dots: Load pre-programmed imagesIt is possible to load icons and images from code. Each frame requires an array of 64 bits for single color and 3X64 bits for mixed color images.
32kB flash can store a lot of 8x8 images !
The Microcontroller is programmed through SPI port using ISP programming, code is written on Arduino IDE 1.0.6 which has some AVR C style Register Settings. An older Atmega32A bootloader is flashed before uploading the application code. Latest IDEs might not work!
Check this Instructable for details.
Conclusion: Brightness vs FlickeringThe badge display is not the brightest. While, it is good for low light environment, the brightness suffers in well lit room. The brightness can be increased by increasing 'On Time' for each dot but that will cause noticeable flickering on the display due to low refresh rate !
One way to solve this is to overclock the mcu @ 20-24 MHz with crystal oscillator instead of using its internal 8 MHz RC oscillator. Hopefully, I will try that later
#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);
}
}
///////////////////////////////////////////////////
//////////////////////////////////////////////////
Comments