Thank you for welcoming me 
I have three code files
One:
sketch_mar21a.ino
int shutterPin = 12;
int buttonPin = 8;
int buttonVal = 0; //somewhere to store the button state
int BUTTONLED = 9;
#define NUM_MAX 4
#define ROTATE 270
#define DIN_PIN 11 //
#define CS_PIN 10 //
#define CLK_PIN 13 //
#include "max7219.h"
#include "fonts.h"
void setup() {
// put your setup code here, to run once:
Serial.begin(9600); // open the serial port at 9600 bps:
pinMode(shutterPin, OUTPUT);
digitalWrite(shutterPin, HIGH);
pinMode(BUTTONLED, OUTPUT);
digitalWrite(BUTTONLED, HIGH);
pinMode(buttonPin, INPUT);
digitalWrite(buttonPin, HIGH); //enable internal pull up resistor
initMAX7219();
sendCmdAll(CMD_SHUTDOWN,1);
sendCmdAll(CMD_INTENSITY,15);
}
void loop() {
// put your main code here, to run repeatedly:
buttonVal = digitalRead(buttonPin);
Serial.println(buttonVal);
delay(200);
if (buttonVal == LOW) {
digitalWrite(BUTTONLED, LOW);
takePhoto();
printStringWithShift("2 LEFT",0);
delay(2000);
takePhoto();
printStringWithShift("LAST 1",0);
delay(2000);
takePhoto();
printStringWithShift("DONE",0);
delay(3000);
printStringWithShift(" ",0);
digitalWrite(BUTTONLED, HIGH);
}
}
int showChar(char ch, const uint8_t *data)
{
int len = pgm_read_byte(data);
int i,w = pgm_read_byte(data + 1 + ch * len);
for (i = 0; i < w; i++)
scr[NUM_MAX*8 + i] = pgm_read_byte(data + 1 + ch * len + 1 + i);
scr[NUM_MAX*8 + i] = 0;
return w;
}
// =======================================================================
void printCharWithShift(unsigned char c, int shiftDelay) {
if (c < ' ' || c > MAX_CHAR) return;
c -= 32;
int w = showChar(c, font);
for (int i=0; i<w+1; i++) {
delay(shiftDelay);
scrollLeft();
refreshAll();
}
}
// =======================================================================
void printStringWithShift(const char* s, int shiftDelay){
while (*s) {
printCharWithShift(*s++, shiftDelay);
}
}
// =======================================================================
void takePhoto() {
printStringWithShift(" 10 9 8 7 6 5 4 3 2 1 ",20);
printStringWithShift("SMILE",0);
delay(1000);
digitalWrite(shutterPin, LOW); // turn the LED off by making the voltage LOW
printStringWithShift(" ",0);
delay(1000);
digitalWrite(shutterPin, HIGH);
}
two
max7219.h
// MAX7219 functions by Pawel A. Hernik
// MAX7219 commands:
#define CMD_NOOP 0
#define CMD_DIGIT0 1
#define CMD_DIGIT1 2
#define CMD_DIGIT2 3
#define CMD_DIGIT3 4
#define CMD_DIGIT4 5
#define CMD_DIGIT5 6
#define CMD_DIGIT6 7
#define CMD_DIGIT7 8
#define CMD_DECODEMODE 9
#define CMD_INTENSITY 10
#define CMD_SCANLIMIT 11
#define CMD_SHUTDOWN 12
#define CMD_DISPLAYTEST 15
byte scr[NUM_MAX*8 + 8]; // +8 for scrolled char
void sendCmdAll(byte cmd, byte data)
{
digitalWrite(CS_PIN, LOW);
for (int i = NUM_MAX-1; i>=0; i--) {
shiftOut(DIN_PIN, CLK_PIN, MSBFIRST, cmd);
shiftOut(DIN_PIN, CLK_PIN, MSBFIRST, data);
}
digitalWrite(CS_PIN, HIGH);
}
void refreshAllRot270()
{
byte mask = 0x01;
for (int c = 0; c < 8; c++) {
digitalWrite(CS_PIN, LOW);
for(int i=NUM_MAX-1; i>=0; i--) {
byte bt = 0;
for(int b=0; b<8; b++) {
bt<<=1;
if(scr[i * 8 + b] & mask) bt|=0x01;
}
shiftOut(DIN_PIN, CLK_PIN, MSBFIRST, CMD_DIGIT0 + c);
shiftOut(DIN_PIN, CLK_PIN, MSBFIRST, bt);
}
digitalWrite(CS_PIN, HIGH);
mask<<=1;
}
}
void refreshAllRot90()
{
byte mask = 0x80;
for (int c = 0; c < 8; c++) {
digitalWrite(CS_PIN, LOW);
for(int i=NUM_MAX-1; i>=0; i--) {
byte bt = 0;
for(int b=0; b<8; b++) {
bt>>=1;
if(scr[i * 8 + b] & mask) bt|=0x80;
}
shiftOut(DIN_PIN, CLK_PIN, MSBFIRST, CMD_DIGIT0 + c);
shiftOut(DIN_PIN, CLK_PIN, MSBFIRST, bt);
}
digitalWrite(CS_PIN, HIGH);
mask>>=1;
}
}
void refreshAll() {
#if ROTATE==270
refreshAllRot270();
#elif ROTATE==90
refreshAllRot90();
#else
for (int c = 0; c < 8; c++) {
digitalWrite(CS_PIN, LOW);
for(int i=NUM_MAX-1; i>=0; i--) {
shiftOut(DIN_PIN, CLK_PIN, MSBFIRST, CMD_DIGIT0 + c);
shiftOut(DIN_PIN, CLK_PIN, MSBFIRST, scr[i * 8 + c]);
}
digitalWrite(CS_PIN, HIGH);
}
#endif
}
void clr()
{
for (int i = 0; i < NUM_MAX*8; i++) scr[i] = 0;
}
void scrollLeft()
{
for(int i=0; i < NUM_MAX*8+7; i++) scr[i] = scr[i+1];
}
void invert()
{
for (int i = 0; i < NUM_MAX*8; i++) scr[i] = ~scr[i];
}
void initMAX7219()
{
pinMode(DIN_PIN, OUTPUT);
pinMode(CLK_PIN, OUTPUT);
pinMode(CS_PIN, OUTPUT);
digitalWrite(CS_PIN, HIGH);
sendCmdAll(CMD_DISPLAYTEST, 0);
sendCmdAll(CMD_SCANLIMIT, 7);
sendCmdAll(CMD_DECODEMODE, 0);
sendCmdAll(CMD_INTENSITY, 1);
sendCmdAll(CMD_SHUTDOWN, 0);
clr();
refreshAll();
}
three:
fonts.h
#define MAX_CHAR ('~'+26)
const uint8_t font[] PROGMEM = {6,
2, B00000000, B00000000, B00000000, B00000000, B00000000, // space
1, B01011111, B00000000, B00000000, B00000000, B00000000, // !
3, B00000011, B00000000, B00000011, B00000000, B00000000, // "
5, B00010100, B00111110, B00010100, B00111110, B00010100, // #
4, B00100100, B01101010, B00101011, B00010010, B00000000, // $
5, B01100011, B00010011, B00001000, B01100100, B01100011, // %
5, B00110110, B01001001, B01010110, B00100000, B01010000, // &
1, B00000011, B00000000, B00000000, B00000000, B00000000, // '
3, B00011100, B00100010, B01000001, B00000000, B00000000, // (
3, B01000001, B00100010, B00011100, B00000000, B00000000, // )
5, B00101000, B00011000, B00001110, B00011000, B00101000, // *
5, B00001000, B00001000, B00111110, B00001000, B00001000, // +
2, B10110000, B01110000, B00000000, B00000000, B00000000, // ,
4, B00001000, B00001000, B00001000, B00001000, B00000000, // -
1, B01000000, B00000000, B00000000, B00000000, B00000000, // .
3, B01100000, B00011100, B00000011, B00000000, B00000000, // /
4, B00111110, B01000001, B01000001, B00111110, B00000000, // 0
3, B01000010, B01111111, B01000000, B00000000, B00000000, // 1
4, B01100010, B01010001, B01001001, B01000110, B00000000, // 2
4, B00100010, B01000001, B01001001, B00110110, B00000000, // 3
4, B00011000, B00010100, B00010010, B01111111, B00000000, // 4
4, B00100111, B01000101, B01000101, B00111001, B00000000, // 5
4, B00111110, B01001001, B01001001, B00110010, B00000000, // 6
4, B01100001, B00010001, B00001001, B00000111, B00000000, // 7
4, B00110110, B01001001, B01001001, B00110110, B00000000, // 8
4, B00100110, B01001001, B01001001, B00111110, B00000000, // 9
1, B01000100, B00000000, B00000000, B00000000, B00000000, // :
2, B10000000, B01010000, B00000000, B00000000, B00000000, // ;
3, B00010000, B00101000, B01000100, B00000000, B00000000, // <
3, B00010100, B00010100, B00010100, B00000000, B00000000, // =
3, B01000100, B00101000, B00010000, B00000000, B00000000, // >
4, B00000010, B01011001, B00001001, B00000110, B00000000, // ?
5, B00111110, B01001001, B01010101, B01011101, B00001110, // @
4, B01111110, B00010001, B00010001, B01111110, B00000000, // A
4, B01111111, B01001001, B01001001, B00110110, B00000000, // B
4, B00111110, B01000001, B01000001, B00100010, B00000000, // C
4, B01111111, B01000001, B01000001, B00111110, B00000000, // D
4, B01111111, B01001001, B01001001, B01000001, B00000000, // E
4, B01111111, B00001001, B00001001, B00000001, B00000000, // F
4, B00111110, B01000001, B01001001, B01111010, B00000000, // G
4, B01111111, B00001000, B00001000, B01111111, B00000000, // H
3, B01000001, B01111111, B01000001, B00000000, B00000000, // I
4, B00110000, B01000000, B01000001, B00111111, B00000000, // J
4, B01111111, B00001000, B00010100, B01100011, B00000000, // K
4, B01111111, B01000000, B01000000, B01000000, B00000000, // L
5, B01111111, B00000010, B00001100, B00000010, B01111111, // M
5, B01111111, B00000100, B00001000, B00010000, B01111111, // N
4, B00111110, B01000001, B01000001, B00111110, B00000000, // O
4, B01111111, B00001001, B00001001, B00000110, B00000000, // P
4, B00111110, B01000001, B01000001, B10111110, B00000000, // Q
4, B01111111, B00001001, B00001001, B01110110, B00000000, // R
4, B00100110, B01001001, B01001001, B00110010, B00000000, // S
5, B00000001, B00000001, B01111111, B00000001, B00000001, // T
4, B00111111, B01000000, B01000000, B00111111, B00000000, // U
5, B00001111, B00110000, B01000000, B00110000, B00001111, // V
5, B00111111, B01000000, B00111000, B01000000, B00111111, // W
5, B01100011, B00010100, B00001000, B00010100, B01100011, // X
5, B00000111, B00001000, B01110000, B00001000, B00000111, // Y
4, B01100001, B01010001, B01001001, B01000111, B00000000, // Z
2, B01111111, B01000001, B00000000, B00000000, B00000000, // [
4, B00000001, B00000110, B00011000, B01100000, B00000000, // \ backslash
2, B01000001, B01111111, B00000000, B00000000, B00000000, // ]
3, B00000010, B00000001, B00000010, B00000000, B00000000, // hat
4, B01000000, B01000000, B01000000, B01000000, B00000000, // _
2, B00000001, B00000010, B00000000, B00000000, B00000000, // `
4, B00100000, B01010100, B01010100, B01111000, B00000000, // a
4, B01111111, B01000100, B01000100, B00111000, B00000000, // b
4, B00111000, B01000100, B01000100, B00101000, B00000000, // c
4, B00111000, B01000100, B01000100, B01111111, B00000000, // d
4, B00111000, B01010100, B01010100, B00011000, B00000000, // e
3, B00000100, B01111110, B00000101, B00000000, B00000000, // f
4, B10011000, B10100100, B10100100, B01111000, B00000000, // g
4, B01111111, B00000100, B00000100, B01111000, B00000000, // h
3, B01000100, B01111101, B01000000, B00000000, B00000000, // i
4, B01000000, B10000000, B10000100, B01111101, B00000000, // j
4, B01111111, B00010000, B00101000, B01000100, B00000000, // k
3, B01000001, B01111111, B01000000, B00000000, B00000000, // l
5, B01111100, B00000100, B01111100, B00000100, B01111000, // m
4, B01111100, B00000100, B00000100, B01111000, B00000000, // n
4, B00111000, B01000100, B01000100, B00111000, B00000000, // o
4, B11111100, B00100100, B00100100, B00011000, B00000000, // p
4, B00011000, B00100100, B00100100, B11111100, B00000000, // q
4, B01111100, B00001000, B00000100, B00000100, B00000000, // r
4, B01001000, B01010100, B01010100, B00100100, B00000000, // s
3, B00000100, B00111111, B01000100, B00000000, B00000000, // t
4, B00111100, B01000000, B01000000, B01111100, B00000000, // u
5, B00011100, B00100000, B01000000, B00100000, B00011100, // v
5, B00111100, B01000000, B00111100, B01000000, B00111100, // w
5, B01000100, B00101000, B00010000, B00101000, B01000100, // x
4, B10011100, B10100000, B10100000, B01111100, B00000000, // y
3, B01100100, B01010100, B01001100, B00000000, B00000000, // z
3, B00001000, B00110110, B01000001, B00000000, B00000000, // {
1, B01111111, B00000000, B00000000, B00000000, B00000000, // |
3, B01000001, B00110110, B00001000, B00000000, B00000000, // }
4, B00001000, B00000100, B00001000, B00000100, B00000000, // ~
5, B00100000, B01010100, B01010100, B11111000, B10000000, // a
4, B00111000, B01000100, B01000110, B00101001, B00000000, // c
4, B00111000, B01010100, B11010100, B10011000, B00000000, // e
3, B01010001, B01111111, B01000100, B00000000, B00000000, // l
4, B01111100, B00000100, B00000110, B01111001, B00000000, // n
4, B00111000, B01000100, B01000110, B00111001, B00000000, // o
4, B01001000, B01010100, B01010110, B00100101, B00000000, // s
3, B01100100, B01010110, B01001101, B00000000, B00000000, // z
3, B01100100, B01010101, B01001100, B00000000, B00000000, // z
5, B01111110, B00010001, B00010001, B11111110, B10000000, // A
4, B00111100, B01000010, B01000011, B00100101, B00000000, // C
5, B01111111, B01001001, B01001001, B11000001, B10000000, // E
4, B01111111, B01001000, B01000100, B01000000, B00000000, // L
5, B01111110, B00000100, B00001010, B00010001, B01111110, // N
4, B00111100, B01000110, B01000011, B00111100, B00000000, // O
4, B00100100, B01001010, B01001011, B00110000, B00000000, // S
4, B01100010, B01010110, B01001011, B01000110, B00000000, // Z
4, B01101001, B01011001, B01001101, B01001011, B00000000, // Z
5, B00111110, B01010101, B01100001, B01010101, B00111110, // :)
5, B00111110, B01100101, B01010001, B01100101, B00111110, // :(
5, B00111110, B01000101, B01010001, B01000101, B00111110, // :o
5, 0x06, 0x1F, 0x7E, 0x1F, 0x06, // heart
5, 0x04, 0x02, 0x7F, 0x02, 0x04, // arrow up
5, 0x10, 0x20, 0x7F, 0x20, 0x10, // arrow down
3, B00000010, B00000101, B00000010, B00000000, B00000000, // deg
5, B00001000, B00001000, B00101010, B00001000, B00001000, // -
};