giobbino
Published © GPL3+

Arduino Nano Pac Man

The legendary Pac Man on an Arduino Nano (or Uno) using TV Out

BeginnerFull instructions provided4,130
Arduino Nano Pac Man

Things used in this project

Hardware components

Arduino Nano R3
Arduino Nano R3
×1
Atari Joystick
Joystick of five pushbuttons, your choice
×1
Pushbutton Switch, Momentary
Pushbutton Switch, Momentary
Joystick of five pushbuttons, your choice
×5
Through Hole Resistor, 100 kohm
Through Hole Resistor, 100 kohm
×5
Through Hole Resistor, 1 kohm
Through Hole Resistor, 1 kohm
×1
Through Hole Resistor, 470 ohm
Through Hole Resistor, 470 ohm
×1
Speaker, Piezo
Speaker, Piezo
×1

Story

Read more

Schematics

Pinout schematics

Code

TVpacman.ino

Arduino
/**************************************************************************
 *  
 *  ARDUINO PAC-MAN 1.2
 *  
 *  Jan/2022  Giovanni Verrua
 *
 *   This program is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with this program.  If not, see <https://www.gnu.org/licenses/>.
 * 
 * NOTE: The code isn't optimized. I know that, it could be wrote 
 *       in less lines and some choices I made are quite awful. 
 *       The main reason is that I wrote it learning Arduino, so I 
 *       preferred a code easy to read than a more compact code.
 *       
 *       Also, I faced many strange problems. In example, a simple
 *       variable declaration, an IF sentence, etc. in some cases prevented
 *       the Arduino Nano from boot. Specifically, I couldn't use the 
 *       TV.print() function (that's the reason to use bitmap for the score
 *       and the lives) and I also have had serious troubles where the 
 *       ghosts slow the speed when they are "haunted" (I mean: when you eat
 *       the magic pill, also called "happy hour" in the comments ;-) or to 
 *       make them flashing at the 3 last seconds of the happy hour.
 *       
 *       So, forgive the sometimes strange code, but I've lost more time
 *       trying to fix this kind of problems than to wrote the whole code.
 *       
 *       -- I wrote the game from scratch instead to port it from another 
 *       platform. Since I'm not a game designer and honestly I have  
 *       no skill about that, I'm sure there's a better way to 
 *       write the ghosts AI. My ghosts are AI: Artificially Idiots.
 *       Sorry for that.
 *           
 *   Connections to Arduino Uno/Nano:
 *    
 *   Connect buttons to: pin 2 and +5V (button up), 
 *                       pin 3 and +5V (button down),
 *                       pin 4 and +5V (button left),
 *                       pin 5 and +5V (but.right),
 *                       pin 6 and +5V (button Fire / Start)
 *                       
 *   (note: you can use an Atari compatible Joystick too)                     
 *                       
 *   Connect 100 kohm pulldown resistors between pin 2 and GND, 
 *                                               pin 3 and GND,   
 *                                               pin 4 and GND,
 *                                               pin 5 and GND,
 *                                               pin 6 and GND
 *   
 *   TV composite out: 
 *   Connect  1k ohm resistor from pin 9 to TV out (+)
 *   Connect 470 ohm resistor from pin 7 to TV out (+)   
 *   Connect GND                         to TV out (-)
 *   
 *   Audio:
 *   Connect a speaker between pin 11 and GND
 * 
 **************************************************************************/

#include <TVout.h>
#include <fontALL.h>
#include "bitmap.h"
#include "pitches.h"


//You can use buttons or a Joystick Atari compatible
#define BUTTON_UP     2   
#define BUTTON_DOWN   3
#define BUTTON_LEFT   4
#define BUTTON_RIGHT  5
#define BUTTON_START  6  //digital - button 

#define PAC_STARTX   48 //pacman X position 
#define PAC_STARTY   61 //pacman Y position


#define GAME_SPEED 30 //higher value, lower speed
#define GHOST_RELEASE_DELAY  1000 //how many millisec between 2 ghosts release

#define HOWMANYGHOSTS 4  //USED FOR DEBUG. MAX 4 GHOSTS (UNLESS YOU CHANGE THE GHOSTS ARRAY DECLARATIONS AND RESET)
#define EATGHOSTSECS  10 //TIME ALLOWED TO EAT GHOSTS (HAPPY HOUR)


TVout TV;

int Score = 0;
int lives = 3;

int gamSt = 0;  //0 = menu, 1 = in game, 2 = game over

int FoodPosY[8]   =       {5,15,25,35,55,65,75,85};
    
int FoodPosX[12]   =      {  5, 15, 25, 34, 44, 59, 70, 84, 94,103,113,122}; 

//This declaration is just for explaining how the food and pills are. 
//if you need to modify something, must change in reset_food() too.
int FoodMatr[8][12] = {   {  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1},    //5
                          {  2,  0,  1,  0,  1,  1,  1,  1,  0,  1,  0,  2},    //15
                          {  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1},    //25    
                          {  1,  1,  1,  1,  0,  0,  0,  0,  1,  1,  1,  1},    //35
                          {  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1},    //55
                          {  1,  2,  1,  1,  1,  1,  1,  1,  1,  1,  2,  1},    //65
                          {  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1},    //75
                          {  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1} };  //85


          int gstPosX [4] = {51,52,53,54};  //ghosts position
          int gstPosY [4] = {41,41,41,41};  //ghosts position
          int gstDire [4] = {1,1,1,1};  //ghosts direction 0=north, 1=east, 2=south, 3=west 


//===================================================================================== JINGLE
void  Jingle(){   //Playing pac-man jingle
  
TV.tone(NOTE_B4 ,100); delay(120);
TV.tone(NOTE_B5 ,100); delay(120);
TV.tone(NOTE_FS5,100); delay(120);
TV.tone(NOTE_DS5,100); delay(120);
TV.tone(NOTE_FS5,120); delay(200);
TV.tone(NOTE_DS5,150); delay(250);

TV.tone(NOTE_C5 ,100); delay(120);
TV.tone(NOTE_C6 ,100); delay(120);
TV.tone(NOTE_G5 ,100); delay(120);
TV.tone(NOTE_E5 ,100); delay(120);
TV.tone(NOTE_C6 ,120); delay(200);
TV.tone(NOTE_G5 ,150); delay(250);

TV.tone(NOTE_B4 ,100); delay(120);
TV.tone(NOTE_B5 ,100); delay(120);
TV.tone(NOTE_FS5,100); delay(120);
TV.tone(NOTE_DS5,100); delay(120);
TV.tone(NOTE_B5 ,120); delay(200);
TV.tone(NOTE_FS5,150); delay(250);

TV.tone(NOTE_DS5,100); delay(120);
TV.tone(NOTE_DS5,100); delay(120);
TV.tone(NOTE_E5 ,100); delay(120);
TV.tone(NOTE_F5 ,100); delay(120);
TV.tone(NOTE_F5 ,100); delay(120);
TV.tone(NOTE_FS5,100); delay(120);
TV.tone(NOTE_G5 ,100); delay(120);
TV.tone(NOTE_G5 ,100); delay(120);
TV.tone(NOTE_GS5,100); delay(120);
TV.tone(NOTE_A5 ,100); delay(120);
TV.tone(NOTE_B5 ,100); delay(120);
}



//===================================================================================== RESET_GHOST
void reset_ghosts() {

     gstPosX[0] = 51; gstPosX[1] = 52; gstPosX[2] = 53; gstPosX[3] = 54;  //ghosts position
     gstPosY[0] = 41; gstPosY[1] = 41; gstPosY[2] = 41; gstPosY[3] = 41;  //ghosts position
     gstDire[0] = 1;  gstDire[1] = 1;  gstDire[2] = 1;  gstDire[3] = 1;  //ghosts direction 0=north, 1=east, 2=south, 3=west 
  
}
          
//===================================================================================== DRAW_FOOD
void draw_food() {
     for (int i=0;i<12;i++){
         for (int j=0;j<8;j++){
          
             if (FoodMatr[j][i] == 1) { //food
                TV.set_pixel(FoodPosX[i],FoodPosY[j],1);
             }
             
             if (FoodMatr[j][i] == 2) { //pill
                TV.set_pixel(FoodPosX[i]-1,FoodPosY[j]+1,1);
                TV.set_pixel(FoodPosX[i]-1,FoodPosY[j]-1,1);
                TV.set_pixel(FoodPosX[i]+1,FoodPosY[j]-1,1);
                TV.set_pixel(FoodPosX[i]+1,FoodPosY[j]+1,1);                
             }
             
          }          
      }
}      

//===================================================================================== RESET_FOOD
void reset_food() {  

  //I tried with a const array for initialization, but i got strange behaviors. I'm sure it's my fault. This isn't elegant but at least it works LOL
  FoodMatr[0][0]=1; FoodMatr[0][1]=1; FoodMatr[0][2]=1; FoodMatr[0][3]=1; FoodMatr[0][4]=1; FoodMatr[0][5]=1; FoodMatr[0][6]=1; FoodMatr[0][7]=1; FoodMatr[0][8]=1; FoodMatr[0][9]=1; FoodMatr[0][10]=1; FoodMatr[0][11]=1 ;
  FoodMatr[1][0]=2; FoodMatr[1][1]=0; FoodMatr[1][2]=1; FoodMatr[1][3]=0; FoodMatr[1][4]=1; FoodMatr[1][5]=1; FoodMatr[1][6]=1; FoodMatr[1][7]=1; FoodMatr[1][8]=0; FoodMatr[1][9]=1; FoodMatr[1][10]=0; FoodMatr[1][11]=2 ;
  FoodMatr[2][0]=1; FoodMatr[2][1]=1; FoodMatr[2][2]=1; FoodMatr[2][3]=1; FoodMatr[2][4]=1; FoodMatr[2][5]=1; FoodMatr[2][6]=1; FoodMatr[2][7]=1; FoodMatr[2][8]=1; FoodMatr[2][9]=1; FoodMatr[2][10]=1; FoodMatr[2][11]=1 ;
  FoodMatr[3][0]=1; FoodMatr[3][1]=1; FoodMatr[3][2]=1; FoodMatr[3][3]=1; FoodMatr[3][4]=0; FoodMatr[3][5]=0; FoodMatr[3][6]=0; FoodMatr[3][7]=0; FoodMatr[3][8]=1; FoodMatr[3][9]=1; FoodMatr[3][10]=1; FoodMatr[3][11]=1 ;
  FoodMatr[4][0]=1; FoodMatr[4][1]=1; FoodMatr[4][2]=1; FoodMatr[4][3]=1; FoodMatr[4][4]=1; FoodMatr[4][5]=1; FoodMatr[4][6]=1; FoodMatr[4][7]=1; FoodMatr[4][8]=1; FoodMatr[4][9]=1; FoodMatr[4][10]=1; FoodMatr[4][11]=1 ;
  FoodMatr[5][0]=1; FoodMatr[5][1]=2; FoodMatr[5][2]=1; FoodMatr[5][3]=1; FoodMatr[5][4]=1; FoodMatr[5][5]=1; FoodMatr[5][6]=1; FoodMatr[5][7]=1; FoodMatr[5][8]=1; FoodMatr[5][9]=1; FoodMatr[5][10]=2; FoodMatr[5][11]=1 ;
  FoodMatr[6][0]=1; FoodMatr[6][1]=1; FoodMatr[6][2]=1; FoodMatr[6][3]=1; FoodMatr[6][4]=1; FoodMatr[6][5]=1; FoodMatr[6][6]=1; FoodMatr[6][7]=1; FoodMatr[6][8]=1; FoodMatr[6][9]=1; FoodMatr[6][10]=1; FoodMatr[6][11]=1 ;
  FoodMatr[7][0]=1; FoodMatr[7][1]=1; FoodMatr[7][2]=1; FoodMatr[7][3]=1; FoodMatr[7][4]=1; FoodMatr[7][5]=1; FoodMatr[7][6]=1; FoodMatr[7][7]=1; FoodMatr[7][8]=1; FoodMatr[7][9]=1; FoodMatr[7][10]=1; FoodMatr[7][11]=1 ;

}      

//===================================================================================== SETUP
void setup() {  
    
    TV.begin(_PAL); //128x96 default
        
    pinMode(BUTTON_UP,INPUT);
    pinMode(BUTTON_DOWN,INPUT);
    pinMode(BUTTON_LEFT,INPUT);
    pinMode(BUTTON_RIGHT,INPUT);
    pinMode(BUTTON_START,INPUT);
    
    gamSt = 0;        
}

//===================================================================================== DRAW_SCORE
//for some reason I can't use the tv.print() function: it hangs the sketch 
//(it compiles fine but after upload it doesn't start). So I must to write the
//score using bitmaps.

void draw_score() {

 int pos = 30;
 int num = 0;
 int zero = 0;

  int a = Score /10;
  int b = Score /100;
  int c = Score /1000;
  int d = Score /10000;
  
  num = d;      if (num > 0 || zero !=0 ) { draw_numbers(num,pos); pos+=8; zero = 1; }
  num = c-d*10; if (num > 0 || zero !=0 ) { draw_numbers(num,pos); pos+=8; zero = 1; }
  num = b-c*10; if (num > 0 || zero !=0 ) { draw_numbers(num,pos); pos+=8; zero = 1; }
  num = a-b*10; if (num > 0 || zero !=0 ) { draw_numbers(num,pos); pos+=8; zero = 1; }
  num = Score-a*10;                         draw_numbers(num,pos); 
  
}  

//===================================================================================== DRAW_NUMBERS
//for some reason I can't use the tv.print() function: it hangs the sketch 
//(it compiles fine but after upload it doesn't start). So I must to write the
//score using bitmaps.
void draw_numbers(uint8_t num, uint8_t pos ) {
  
               if (num == 0) TV.bitmap(  pos,88,nu0);
               if (num == 1) TV.bitmap(  pos,88,nu1);
               if (num == 2) TV.bitmap(  pos,88,nu2);
               if (num == 3) TV.bitmap(  pos,88,nu3);
               if (num == 4) TV.bitmap(  pos,88,nu4);
               if (num == 5) TV.bitmap(  pos,88,nu5);
               if (num == 6) TV.bitmap(  pos,88,nu6);
               if (num == 7) TV.bitmap(  pos,88,nu7);
               if (num == 8) TV.bitmap(  pos,88,nu8);
               if (num == 9) TV.bitmap(  pos,88,nu9);            

}


//===================================================================================== COLLISION
unsigned char collision(uint8_t x, uint8_t y, uint8_t dir) {

  //-----------------------------------------------------------------------------------------------------north
  if (dir == 0){
    if ( TV.get_pixel(x,y-1)==1 || TV.get_pixel(x+7,y-1)==1 ) return 1;
     for (int i=1;i<6;i++){
        if ( TV.get_pixel(x+i,y-1)==1 && TV.get_pixel(x+i+1,y-1)==1 ) return 1; //must to have at least 2 pixel in front of it to represent a wall (1 pixel represent food or pill)
     }           
  }
  
  //-----------------------------------------------------------------------------------------------------east
  if (dir == 1){
     if ( TV.get_pixel(x+8,y)==1 || TV.get_pixel(x+8,y+7)==1 ) return 1; 
     for (int i=1;i<6;i++){
        if ( TV.get_pixel(x+8,y+i)==1 && TV.get_pixel(x+8,y+i+1)==1 ) return 1;  //must to have at least 2 pixel in front of it to represent a wall (1 pixel represent food or pill)
     }           
  }

  //-----------------------------------------------------------------------------------------------------south
  if (dir == 2){    
    if ( TV.get_pixel(x,y+8)==1 || TV.get_pixel(x+7,y+8)==1 ) return 1;
     for (int i=1;i<6;i++){
        if ( TV.get_pixel(x+i,y+8)==1 && TV.get_pixel(x+i+1,y+8)==1 ) return 1; //must to have at least 2 pixel in front of it to represent a wall (1 pixel represent food or pill)
     }           
  }

  //-----------------------------------------------------------------------------------------------------west
  if (dir == 3){
     if ( TV.get_pixel(x-1,y)==1 || TV.get_pixel(x-1,y+7)==1 ) return 1;
     for (int i=1;i<6;i++){
        if ( TV.get_pixel(x-1,y+i)==1 && TV.get_pixel(x-1,y+i+1)==1 ) return 1; //must to have at least 2 pixel in front of it to represent a wall (1 pixel represent food or pill)
     }           
  }  

  return 0;
}  

//===================================================================================== LOOP
void loop() {
        
  bool every_2 = false;
  //-----------------------------------------------------------------------------------------------------MENU              
  if (gamSt == 0){   //MENU

        TV.clear_screen();           
        TV.bitmap(0,  0, logo);
        TV.bitmap(0, 33, start);

        delay(1000);     

        while ( digitalRead(BUTTON_START) == 0){}                  
         gamSt = 1; 
         delay(300);
         
  }
    
 
 //-----------------------------------------------------------------------------------------------------IN GAME
 
  if (gamSt == 1){   // IN GAME

     Score = 0;
     lives = 3;

     //---------------------------------
     //drawing once the grid and the food before the jingle() - not needed, just for show
     TV.clear_screen();     
     TV.bitmap(00,00,grid); 
     reset_food();                         
     draw_food(); 
     Jingle();
     //---------------------------------
      

     while (lives > 0){    

          int eatGhosts = 0;
          int oldDire = 1;  //old pacman direction 
        
          unsigned long mill = millis() ;  //delay - aliens
          unsigned long relg = millis() ;  //delay - release ghosts
          unsigned long eatg = millis() ;  //delay - eat ghosts
          

          int pacPosX = PAC_STARTX; //pacman X position 
          int pacPosY = PAC_STARTY; //pacman Y position
          int pacDire = 1;  //pacman direction 0=north, 1=east, 2=south, 3=west > changing with wheel or buttons                   

          int ghChg[4] = {0,0,0,0};  //ghost change direction  
          int ghSts[4] = {0,0,0,0};  //ghost status (1=eaten, 0=alive) - when eatGhosts = 1
        

          int endfood = 0; // 0 = all eaten, 1 = some food/pills left yet    
          int gotcha = 0;   
          int numofgh = 0;
           
           endfood = 1;     

           TV.clear_screen();
           TV.bitmap(00,00,grid);
                    
           reset_ghosts();           
           reset_food();            
           draw_food(); 
           
           //-----------------------------------------------------------------------------------------------------Main Cycle-begin-\
                      
           while ( endfood != 0 && lives > 0 ) {              
                                      
             if (mill + GAME_SPEED < millis()){  //the game move all at the same speed                

                if (every_2 ) every_2 = false; else every_2 = true;
      
                if (  numofgh < HOWMANYGHOSTS && relg + GHOST_RELEASE_DELAY < millis() ) { numofgh++; relg = millis(); }
      
                     
               //----------------------------------------------------------------------------------------------\ 
               //DON'T MOVE THIS PART FROM HERE! IT MUST TO DELETE ALL THE GHOSTS BEFORE TO CHECK THE OBSTACLES 
               //OR THE GHOSTS WILL BE CONFUSED BY THE PRESENCE OF OTHER GHOSTS!!!
               for (int i=0;i<numofgh;i++){  
                   TV.bitmap(gstPosX[i],gstPosY[i],blk);  //delete all ghosts before to check obstacles.        
                } 
                TV.bitmap(pacPosX,pacPosY,blk);
                //----------------------------------------------------------------------------------------------/

      
                //----------------------------------------------------3 secs to the end of happy hour! Ghosts are flashing
                if (eatGhosts == 1 && eatg + EATGHOSTSECS*1000 -3000 < millis()) {
                     eatGhosts = 2;     
                }

                //----------------------------------------------------end of happy hour! Ghosts are hunting you again!
                if (eatGhosts > 0 && eatg + EATGHOSTSECS*1000 < millis()) {
                     eatGhosts = 0;     
                     ghSts[0] = 0; ghSts[1] = 0; ghSts[2] = 0; ghSts[3] = 0;                     
                }   
        
                //----------------------------------------------------------------------------------------------\                                                   

                oldDire = pacDire ;
                if ( digitalRead(BUTTON_UP   ) == 1) pacDire = 0; //north
                if ( digitalRead(BUTTON_RIGHT) == 1) pacDire = 1; //east
                if ( digitalRead(BUTTON_DOWN ) == 1) pacDire = 2; //south
                if ( digitalRead(BUTTON_LEFT ) == 1) pacDire = 3; //west
                                   
                if (collision(pacPosX,pacPosY,pacDire) == 1 && pacDire != oldDire ) pacDire = oldDire ;
                
                if (collision(pacPosX,pacPosY,pacDire) == 0){                
          
                      if (pacDire == 0) pacPosY--; 
                      if (pacDire == 1) pacPosX++; 
                      if (pacDire == 2) pacPosY++; 
                      if (pacDire == 3) pacPosX--; 
          
                      if (pacPosX > 120) pacPosX = 0;
                      if (pacPosX < 0)   pacPosX = 120; 
      
                       //------------------------------------------------------------------------------------------------------check food/pills
                       endfood = 0;
                       for (int i=0;i<12;i++){
                           for (int j=0;j<8;j++){
                               if (FoodMatr[j][i] == 1 || FoodMatr[j][i] == 2 ) {
                                  endfood = 1;  //still some food / pills to eat

                                  //-------------------------------------------------------------------------------------------------------food
                                  if (FoodPosX[i] >= pacPosX && FoodPosX[i] <= pacPosX+7 && FoodPosY[j] >= pacPosY && FoodPosY[j] <= pacPosY+7) {
                                      if (FoodMatr[j][i] == 1) {
                                          FoodMatr[j][i] = 0;
                                          Score ++;
                                          TV.tone(NOTE_G1, 50);
                                      }
                                      if (FoodMatr[j][i] == 2) {
                                          FoodMatr[j][i] = 0;
                                          Score += 10;
                                          eatGhosts = 1;
                                          eatg = millis() ;
                                          TV.tone(NOTE_B5, 50);
                                      }
                                  }    
                                  //-------------------------------------------------------------------------------------------------------pill
                               }
                            }          
                        }

                        if (endfood == 0) Jingle();
                } 
                     
                     
                //----------------------------------------------------------------------------------------------/                 

                //----------------------------------------------------------------------------------------------pac vs ghost collision 
                 gotcha = 0;   
                
                 for (int i=0;i<numofgh;i++){    

                    if (eatGhosts == 0 || ghSts[i] == 0) {  

                        //ghost coming from north
                        if (  gstPosY[i] <=pacPosY    && gstPosY[i]+8 >=pacPosY    &&  ( (gstPosX[i] >=pacPosX && gstPosX[i]+7 <=pacPosX) || (gstPosX[i] <=pacPosX && gstPosX[i]+7 >=pacPosX) ) ) { gotcha = i+1; i == numofgh; }
                        
                        //ghost coming from south
                        if (  pacPosY    <=gstPosY[i] && pacPosY   +8 >=gstPosY[i] &&  ( (gstPosX[i] >=pacPosX && gstPosX[i]+7 <=pacPosX) || (gstPosX[i] <=pacPosX && gstPosX[i]+7 >=pacPosX) ) ) { gotcha = i+1; i == numofgh; }
                        
                        //ghost coming from west
                        if (  gstPosX[i] <=pacPosX    && gstPosX[i]+8 >=pacPosX    &&  ( (gstPosY[i] >=pacPosY && gstPosY[i]+7 <=pacPosY) || (gstPosY[i] <=pacPosY && gstPosY[i]+7 >=pacPosY) ) ) { gotcha = i+1; i == numofgh; }
                                           
                        //ghost coming from south
                        if (  pacPosX    <=gstPosX[i] && pacPosX   +8 >=gstPosX[i] &&  ( (gstPosY[i] >=pacPosY && gstPosY[i]+7 <=pacPosY) || (gstPosY[i] <=pacPosY && gstPosY[i]+7 >=pacPosY) ) ) { gotcha = i+1; i == numofgh; }                    
                    }    
                 }

                 if (gotcha > 0 ) {

                    if (eatGhosts == 0) {
                        //------------------------------------------------------------- the got you! ----------
                        lives --;                                          
                        
                        for (int i=0;i<5;i++){                   
                           TV.tone(NOTE_G1*(5-i)*10, 100);
                           TV.bitmap(pacPosX,pacPosY,p1w); delay(50) ; 
                           TV.bitmap(pacPosX,pacPosY,p1s); delay(50) ;
                           TV.bitmap(pacPosX,pacPosY,p1e); delay(50) ;
                           TV.bitmap(pacPosX,pacPosY,p1n); delay(50) ;
                        }                   
                        delay(1000);
                        relg = millis() ;
                        pacPosX = PAC_STARTX; //pacman X position 
                        pacPosY = PAC_STARTY; //pacman Y position
                        pacDire = 1;  //pacman direction 0=north, 1=east, 2=south, 3=west > changing with wheel or buttons 
                        oldDire = 1;  //old pacman direction 
                        
                        ghChg[0] = 0; ghChg[1] = 0; ghChg[2] = 0; ghChg[3] = 0;   //ghost change direction  
                        gotcha = 0;   
                        numofgh = 0;
                                            
                        if (lives >0) {
                           TV.clear_screen();
                           TV.bitmap(00,00,grid);                    
                           draw_food(); 
                           reset_ghosts();
                        }      
                     }  
                     //------------------------------------------------------------- you got a ghost!-------
                     else {   // eatGhosts == 1   
                          TV.tone(NOTE_B6, 200);                       
                          gstPosX[gotcha-1] = 51;
                          gstPosY[gotcha-1] = 41;
                          Score += 20;                          
                                     
                     }
                 }   

               
               //---------------------------------------------------------------------------ghost moving-begin-\
      
                for (int i=0;i<numofgh;i++){ //DEBUG //<4 ma bisogna capire come fare per differenziare le direzioni dei fantasmi
      
                   ghChg[i] = 0;
                   
                   //direction 0=north, 1=east, 2=south, 3=west
             
                   //----------------------------------------------------------------------------------------north                                         
                   if (gstDire[i]==0 && ghChg[i]==0 && collision(gstPosX[i],gstPosY[i],gstDire[i]) == 1){  //
                       if (pacPosX < gstPosX[i] && eatGhosts == 0){           //if (random(1,3) == 1){
                           if (collision(gstPosX[i],gstPosY[i],3) == 0) { gstDire[i] = 3; ghChg[i] = 1; } else {  //n -> w
                           if (collision(gstPosX[i],gstPosY[i],1) == 0) { gstDire[i] = 1; ghChg[i] = 1; } }       //n -> e
                       }
                       else {
                           if (collision(gstPosX[i],gstPosY[i],1) == 0) { gstDire[i] = 1; ghChg[i] = 1; } else {  //n -> e
                           if (collision(gstPosX[i],gstPosY[i],3) == 0) { gstDire[i] = 3; ghChg[i] = 1; } }       //n -> w
                       }
                       if ( ghChg[i]==0 )  {gstDire[i]=2; ghChg[i] = 1; } //n -> s}  //means it can only go back   
                   }
                   //----------------------------------------------------------------------------------------east                
                   if (gstDire[i]==1 && ghChg[i]==0 && collision(gstPosX[i],gstPosY[i],gstDire[i]) == 1){
                      if (pacPosY > gstPosY[i] && eatGhosts == 0){           //if (random(1,3) == 1){
                          if (collision(gstPosX[i],gstPosY[i],2) == 0) { gstDire[i] = 2; ghChg[i] = 1; }  else {  //e -> s               
                          if (collision(gstPosX[i],gstPosY[i],0) == 0) { gstDire[i] = 0; ghChg[i] = 1; } }        //e -> n 
                        }
                       else {
                          if (collision(gstPosX[i],gstPosY[i],0) == 0) { gstDire[i] = 0; ghChg[i] = 1; }  else {  //e -> n               
                          if (collision(gstPosX[i],gstPosY[i],2) == 0) { gstDire[i] = 2; ghChg[i] = 1; } }        //e -> s 
                       }                             
                       if ( ghChg[i]==0 )  {gstDire[i]=3; ghChg[i] = 1; } //e -> w}  //means it can only go back 
                   }
                   //----------------------------------------------------------------------------------------south                
                   if (gstDire[i]==2 && ghChg[i]==0 && collision(gstPosX[i],gstPosY[i],gstDire[i]) == 1){
                       if (pacPosX > gstPosX[i] && eatGhosts == 0){           //if (random(1,3) == 1){
                           if (collision(gstPosX[i],gstPosY[i],1) == 0) { gstDire[i] = 1; ghChg[i] = 1; } else {   //s -> e               
                           if (collision(gstPosX[i],gstPosY[i],3) == 0) { gstDire[i] = 3; ghChg[i] = 1; } }        //s -> w 
                       }  
                       else {
                           if (collision(gstPosX[i],gstPosY[i],3) == 0) { gstDire[i] = 3; ghChg[i] = 1; } else {   //s -> w               
                           if (collision(gstPosX[i],gstPosY[i],1) == 0) { gstDire[i] = 1; ghChg[i] = 1; } }        //s -> e 
                       }  
                       if ( ghChg[i]==0 )  {gstDire[i]=0; ghChg[i] = 1; } //s -> n}  //means it can only go back 
                   }
                   //----------------------------------------------------------------------------------------west                
                   if (gstDire[i]==3 && ghChg[i]==0 && collision(gstPosX[i],gstPosY[i],gstDire[i]) == 1){
                       if (pacPosY < gstPosY[i] && eatGhosts == 0){           //if (random(1,3) == 1){
                           if (collision(gstPosX[i],gstPosY[i],0) == 0) { gstDire[i] = 0; ghChg[i] = 1; } else {   //w -> n               
                           if (collision(gstPosX[i],gstPosY[i],2) == 0) { gstDire[i] = 2; ghChg[i] = 1; } }        //w -> s 
                       }  
                       else {
                           if (collision(gstPosX[i],gstPosY[i],2) == 0) { gstDire[i] = 2; ghChg[i] = 1; } else {   //w -> s               
                           if (collision(gstPosX[i],gstPosY[i],0) == 0) { gstDire[i] = 0; ghChg[i] = 1; } }        //w -> n 
                       }  
                       if ( ghChg[i]==0 )  {gstDire[i]=1; ghChg[i] = 1; } //w -> e}  //means it can only go back 
                   }
               
                   
                 }  //next i
      
                 
               
                for (int i=0;i<numofgh;i++){ 
                     
                  
                    if (ghChg[i]==0  && random(1,3) == 1){ 
                        
                        //----------------------------------------------------------------------------------------west                                 
                        if (gstDire[i]==3 && ghChg[i]==0){  //west
                           if (pacPosY < gstPosY[i] && eatGhosts == 0){           //if (random(1,3) == 1){                                                    
                               if ( collision(gstPosX[i],gstPosY[i],0) == 0 && ghChg[i]==0) {gstDire[i]=0;ghChg[i] = 1; } //w -> n
                               if (random(1,5)==2){ 
                               if ( collision(gstPosX[i],gstPosY[i],2) == 0 && ghChg[i]==0) {gstDire[i]=2;ghChg[i] = 1; } //w -> s                         
                               }
                            }                        
                           else {                           
                               if ( collision(gstPosX[i],gstPosY[i],2) == 0 && ghChg[i]==0) {gstDire[i]=2;ghChg[i] = 1; } //w -> s
                               if (random(1,5)==2){ 
                               if ( collision(gstPosX[i],gstPosY[i],0) == 0 && ghChg[i]==0) {gstDire[i]=0;ghChg[i] = 1; } //w -> n                                              
                               }
                            }                       
                        }
                                      
                        //----------------------------------------------------------------------------------------north
                        if (gstDire[i]==0 && ghChg[i]==0){  //north
                              if (pacPosX < gstPosX[i] && eatGhosts == 0){           //if (random(1,3) == 1){
                                  if ( collision(gstPosX[i],gstPosY[i],1) == 0 && ghChg[i]==0) {gstDire[i]=1;ghChg[i] = 1; } //n -> e                       
                                  if (random(1,5)==2){ 
                                  if ( collision(gstPosX[i],gstPosY[i],3) == 0 && ghChg[i]==0) {gstDire[i]=3;ghChg[i] = 1; } //n -> w                            
                                  }
                              } 
                        
                              else {                                                  
                                  if ( collision(gstPosX[i],gstPosY[i],3) == 0 && ghChg[i]==0) {gstDire[i]=3;ghChg[i] = 1; } //n -> w
                                  if (random(1,5)==2){ 
                                  if ( collision(gstPosX[i],gstPosY[i],1) == 0 && ghChg[i]==0) {gstDire[i]=1;ghChg[i] = 1; } //n -> e                                         
                                  }
                              }     
                        }                   
                        
                        //----------------------------------------------------------------------------------------east                         
                        if (gstDire[i]==1 && ghChg[i]==0){  //east      
                             if (pacPosY > gstPosY[i] && eatGhosts == 0){           //if (random(1,3) == 1){                                                    
                                  if ( collision(gstPosX[i],gstPosY[i],2) == 0 && ghChg[i]==0) {gstDire[i]=2;ghChg[i] = 1; } //e -> s 
                                  if (random(1,5)==2){ 
                                  if ( collision(gstPosX[i],gstPosY[i],0) == 0 && ghChg[i]==0) {gstDire[i]=0;ghChg[i] = 1; } //e -> n                                                 
                                  }
                              }                        
                             else {                              
                                  if ( collision(gstPosX[i],gstPosY[i],0) == 0 && ghChg[i]==0) {gstDire[i]=0;ghChg[i] = 1; } //e -> n
                                  if (random(1,5)==2){ 
                                  if ( collision(gstPosX[i],gstPosY[i],2) == 0 && ghChg[i]==0) {gstDire[i]=2;ghChg[i] = 1; } //e -> s                                         
                                  }
                             }     
                        }                    
          
                        //----------------------------------------------------------------------------------------south
                        if (gstDire[i]==2 && ghChg[i]==0){  //south 
                           if (pacPosX > gstPosX[i] && eatGhosts == 0){           //if (random(1,3) == 1){                                                                                    
                                  if ( collision(gstPosX[i],gstPosY[i],3) == 0 && ghChg[i]==0) {gstDire[i]=3;ghChg[i] = 1; } //s -> w 
                                  if (random(1,5)==2){ 
                                  if ( collision(gstPosX[i],gstPosY[i],1) == 0 && ghChg[i]==0) {gstDire[i]=1;ghChg[i] = 1; } //s -> e 
                                  }
                            }                        
                            else {                             
                                  if ( collision(gstPosX[i],gstPosY[i],1) == 0 && ghChg[i]==0) {gstDire[i]=1;ghChg[i] = 1; } //s -> e                 
                                  if (random(1,5)==2){ 
                                  if ( collision(gstPosX[i],gstPosY[i],3) == 0 && ghChg[i]==0) {gstDire[i]=3;ghChg[i] = 1; } //s -> w 
                                  }
                            }     
                        }                       
                        
                        
                  }     


                  //--------------------------------------------------------------------------------------don't touch the code or will hang Arduino begin ---\
                  //I know that the code isn't optimized and could be written in a more compact way; however if you will touch
                  //this part, even with replicated code, the sketch will hang the Arduino - it drove me crazy and this was
                  //the only way I succeded. If you find a better and working way, or can explain me how it hangs, please
                  //advise me. Thank you!

                //if (eatGhosts == 0 && every_2 ) {  this should work fine and avoid to replicate the IF; instead it hangs the sketch.
                  
                  if (eatGhosts == 0 ) {  //ghosts at normal speed (they're hunting you)                
                     if (gstDire[i] == 0) gstPosY[i]--; 
                     if (gstDire[i] == 1) gstPosX[i]++; 
                     if (gstDire[i] == 2) gstPosY[i]++; 
                     if (gstDire[i] == 3) gstPosX[i]--;     
                                      
                     if (gstPosX[i] > 120) gstPosX[i] = 0; 
                     if (gstPosX[i] < 0)   gstPosX[i] = 120;       
                     if (gstPosX[i] > 120) gstPosX[i] = 0; else if (gstPosX[i] < 0)   gstPosX[i] = 120; 
                  }
                  //-------------------------------------------------------------------------------
                  if ( eatGhosts > 0  && every_2 ) {  //happy hour, the ghosts are haunted and move at half speed                
                     if (gstDire[i] == 0) gstPosY[i]--; 
                     if (gstDire[i] == 1) gstPosX[i]++; 
                     if (gstDire[i] == 2) gstPosY[i]++; 
                     if (gstDire[i] == 3) gstPosX[i]--;     
                                      
                     if (gstPosX[i] > 120) gstPosX[i] = 0; 
                     if (gstPosX[i] < 0)   gstPosX[i] = 120;       
                     if (gstPosX[i] > 120) gstPosX[i] = 0; else if (gstPosX[i] < 0)   gstPosX[i] = 120; 
                  }
                                                      
                  //-----------------------------------------------------------------------draw ghosts                                                         
                 //Again, don't touch this part or the sketch will hang the Arduino!
                 
                 if (eatGhosts == 0) {                  
                       if ( (gstPosX[i] % 2) - (gstPosY[i] % 2) == 0) TV.bitmap(gstPosX[i],gstPosY[i],g1n); 
                       else                                           TV.bitmap(gstPosX[i],gstPosY[i],g2n);
                  }
                  
                  if (eatGhosts == 1) {                  
                       if ( (gstPosX[i] % 2) - (gstPosY[i] % 2) == 0) TV.bitmap(gstPosX[i],gstPosY[i],g1h); 
                       else                                           TV.bitmap(gstPosX[i],gstPosY[i],g2h);  
                  }     

                  if (eatGhosts == 2) {                  
                       if ( (gstPosX[i] % 2) - (gstPosY[i] % 2) == 0) TV.bitmap(gstPosX[i],gstPosY[i],g1h); 
                       else                                           TV.bitmap(gstPosX[i],gstPosY[i],g2n);    
 
                  }
                  //--------------------------------------------------------------------------------------don't touch the code or will hang Arduino end -----/


                  
                   
               }  //next i
               //---------------------------------------------------------------------------ghost moving-end---/  


                
                //--------------------------------------------------------------------------------------------------- draw Pac Man
                if (pacDire == 0) {
                    if ( (pacPosX % 2) - (pacPosY % 2) == 0) { TV.bitmap(pacPosX,pacPosY,p1n); }
                    else                                     { TV.bitmap(pacPosX,pacPosY,p2n); }
                  }
                if (pacDire == 1) {
                    if ( (pacPosX % 2) - (pacPosY % 2) == 0) { TV.bitmap(pacPosX,pacPosY,p1e); }
                    else                                     { TV.bitmap(pacPosX,pacPosY,p2e); }
                  }
                if (pacDire == 2) {
                    if ( (pacPosX % 2) - (pacPosY % 2) == 0) { TV.bitmap(pacPosX,pacPosY,p1s); }
                    else                                     { TV.bitmap(pacPosX,pacPosY,p2s); }
                  }
                if (pacDire == 3) {
                    if ( (pacPosX % 2) - (pacPosY % 2) == 0) { TV.bitmap(pacPosX,pacPosY,p1w); }
                    else                                     { TV.bitmap(pacPosX,pacPosY,p2w); }
                  }
                
               //---------------------------------------------------------------------------------------------------       
               draw_food();   
               draw_score(); 
               draw_numbers( lives, 118 );
      
                //------------------------------------------------------------
                mill = millis();
              }
             
                
               //-----------------------------------------------------------------------------------------------------Main Cycle-end--- /
               
             } //while endfood != 0
              
       } //while lives >0 
       gamSt = 2 ;
   } //if gamst == 1

  //-----------------------------------------------------------------------------------------------------GAME OVER 
  if (gamSt == 2){  //GAME OVER
    gamSt = 0;     
    TV.clear_screen();           
    TV.bitmap(0,  0, logo);
    TV.bitmap(0, 33, over);     
     
    draw_score();    
    delay(1000);
    
    //must to release and press again the button before to continue
    while ( digitalRead(BUTTON_START) == 1){}
    while ( digitalRead(BUTTON_START) == 0){}

  }
  
}

bitmap.h

Arduino
/**
 * PacMan
 *
 */


//ghost 1 normal
PROGMEM const unsigned char g1n[] = {
8, 8, //pictureresolution
  0x3C,0x7E,0xFF,0xDB,0x93,0xFF,0xFF,0xA5};


//ghost 2 normal
PROGMEM const unsigned char g2n[] = {
8, 8, //pictureresolution
  0x3C,0x7E,0xFF,0x93,0xDB,0xFF,0xFF,0xA5};

//ghost 1 haunted
PROGMEM const unsigned char g1h[] = {
8, 8, //pictureresolution
0x3C,0x42,0x81,0xA5,0xED,0x81,0xDB,0xA5};

//ghost 2 haunted
PROGMEM const unsigned char g2h[] = {
8, 8, //pictureresolution
0x3C,0x42,0x81,0xED,0xA5,0x81,0xDB,0xA5};

//pacman 1 east
PROGMEM const unsigned char p1e[] = {
8, 8, //pictureresolution
  0x3C,0x7E,0xF7,0xFF,0xF0,0xFF,0x7E,0x3C};

//pacman 2 east
PROGMEM const unsigned char p2e[] = {
8, 8, //pictureresolution
  0x3C,0x7E,0xF7,0xFC,0xF0,0xFF,0x7E,0x3C};


//pacman 1 north
PROGMEM const unsigned char p1n[] = {
8, 8, //pictureresolution
  0x2C,0x6E,0xEF,0xEB,0xFF,0xFF,0x7E,0x3C};

//pacman 2 north
PROGMEM const unsigned char p2n[] = {
8, 8, //pictureresolution
  0x24,0x66,0xEF,0xEB,0xFF,0xFF,0x7E,0x3C};

//pacman 1 west
PROGMEM const unsigned char p1w[] = {
8, 8, //pictureresolution
0x3C,0x7E,0xEF,0xFF,0x0F,0xFF,0x7E,0x3C};

//pacman 2 west
PROGMEM const unsigned char p2w[] = {
8, 8, //pictureresolution
0x3C,0x7E,0xEF,0x3F,0x0F,0xFF,0x7E,0x3C};

//pacman 1 south
PROGMEM const unsigned char p1s[] = {
8, 8, //pictureresolution
0x3C,0x7E,0xFF,0xFF,0xEB,0xEF,0x6E,0x2C};

//pacman 2 south
PROGMEM const unsigned char p2s[] = {
8, 8, //pictureresolution
0x3C,0x7E,0xFF,0xFF,0xEB,0xEF,0x66,0x24};

//delete ghost/pac
PROGMEM const unsigned char blk[] = {
8, 8, //pictureresolution
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};


//1
PROGMEM const unsigned char nu1[] = {
8, 8, //pictureresolution
0x00,0xFF,0x00,0x08,0x18,0x08,0x08,0x1C};


//2
PROGMEM const unsigned char nu2[] = {  
8, 8, //pictureresolution
0x00,0xFF,0x00,0x3C,0x04,0x3C,0x20,0x3C};


//3
PROGMEM const unsigned char nu3[] = {
8, 8, //pictureresolution
0x00,0xFF,0x00,0x3C,0x04,0x3C,0x04,0x3C};


//4
PROGMEM const unsigned char nu4[] = {
8, 8, //pictureresolution
0x00,0xFF,0x00,0x24,0x24,0x3C,0x04,0x04};


//5
PROGMEM const unsigned char nu5[] = {
8, 8, //pictureresolution
0x00,0xFF,0x00,0x3C,0x20,0x3C,0x04,0x3C};


//6
PROGMEM const unsigned char nu6[] = {
8, 8, //pictureresolution
0x00,0xFF,0x00,0x3C,0x20,0x3C,0x24,0x3C};

//7
PROGMEM const unsigned char nu7[] = {
8, 8, //pictureresolution
0x00,0xFF,0x00,0x3C,0x04,0x08,0x10,0x10};


//8
PROGMEM const unsigned char nu8[] = {
8, 8, //pictureresolution
0x00,0xFF,0x00,0x3C,0x24,0x3C,0x24,0x3C};


//9
PROGMEM const unsigned char nu9[] = {
8, 8, //pictureresolution
0x00,0xFF,0x00,0x3C,0x24,0x3C,0x04,0x3C};

//0
PROGMEM const unsigned char nu0[] = {
8, 8, //pictureresolution
0x00,0xFF,0x00,0x3C,0x24,0x24,0x24,0x3C};

//grid
PROGMEM const unsigned char grid[] = {
  128, 96, //pictureresolution
  0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
  0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x03,
  0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x03,
  0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x03,
  0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x03,
  0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x03,
  0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x03,
  0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x03,
  0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x03,
  0xC0,0x3F,0xF8,0x07,0xFF,0xFF,0xFE,0x01,0x80,0x7F,0xFF,0xFF,0xE0,0x1F,0xFC,0x03,
  0xC0,0x3F,0xF8,0x07,0xFF,0xFF,0xFE,0x01,0x80,0x7F,0xFF,0xFF,0xE0,0x1F,0xFC,0x03,
  0xC0,0x20,0x18,0x04,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x20,0x10,0x04,0x03,
  0xC0,0x20,0x18,0x04,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x20,0x10,0x04,0x03,
  0xC0,0x20,0x18,0x04,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x20,0x10,0x04,0x03,
  0xC0,0x20,0x18,0x04,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x20,0x10,0x04,0x03,
  0xC0,0x20,0x18,0x04,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x20,0x10,0x04,0x03,
  0xC0,0x20,0x18,0x04,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x20,0x10,0x04,0x03,
  0xC0,0x20,0x18,0x04,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x20,0x10,0x04,0x03,
  0xC0,0x20,0x18,0x04,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x20,0x10,0x04,0x03,
  0xC0,0x3F,0xF8,0x07,0xFF,0x00,0xFF,0xFF,0xFF,0xFF,0x00,0xFF,0xE0,0x1F,0xFC,0x03,
  0xC0,0x3F,0xF8,0x07,0xFF,0x00,0xFF,0xFF,0xFF,0xFF,0x00,0xFF,0xE0,0x1F,0xFC,0x03,
  0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x03,
  0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x03,
  0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x03,
  0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x03,
  0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x03,
  0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x03,
  0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x03,
  0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x03,
  0xC0,0x3F,0xF8,0x07,0xFF,0xFF,0xFE,0x01,0x80,0x7F,0xFF,0xFF,0xE0,0x1F,0xFC,0x03,
  0xC0,0x3F,0xF8,0x07,0xFF,0xFF,0xFE,0x01,0x80,0x7F,0xFF,0xFF,0xE0,0x1F,0xFC,0x03,
  0xC0,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x00,0x00,0x00,0x03,
  0xC0,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x00,0x00,0x00,0x03,
  0xC0,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x00,0x00,0x00,0x03,
  0xC0,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x00,0x00,0x00,0x03,
  0xC0,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x00,0x00,0x00,0x03,
  0xC0,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x00,0x00,0x00,0x03,
  0xC0,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x00,0x00,0x00,0x03,
  0xC0,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x00,0x00,0x00,0x03,
  0xFF,0xFF,0xFF,0xFC,0x03,0x00,0xFF,0xFF,0xFC,0x03,0x00,0xC0,0x3F,0xFF,0xFF,0xFF,
  0xFF,0xFF,0xFF,0xFC,0x03,0x00,0xFF,0xFF,0xFC,0x03,0x00,0xC0,0x3F,0xFF,0xFF,0xFF,
  0x00,0x00,0x00,0x00,0x03,0x00,0xC0,0x00,0x00,0x03,0x00,0xC0,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x03,0x00,0xC0,0x00,0x00,0x03,0x00,0xC0,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x03,0x00,0xC0,0x00,0x00,0x03,0x00,0xC0,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x03,0x00,0xC0,0x00,0x00,0x03,0x00,0xC0,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x03,0x00,0xC0,0x00,0x00,0x03,0x00,0xC0,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x03,0x00,0xC0,0x00,0x00,0x03,0x00,0xC0,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x03,0x00,0xC0,0x00,0x00,0x03,0x00,0xC0,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x03,0x00,0xC0,0x00,0x00,0x03,0x00,0xC0,0x00,0x00,0x00,0x00,
  0xFF,0xFF,0xFF,0xFC,0x03,0x00,0xFF,0xFF,0xFF,0xFF,0x00,0xC0,0x3F,0xFF,0xFF,0xFF,
  0xFF,0xFF,0xFF,0xFC,0x03,0x00,0xFF,0xFF,0xFF,0xFF,0x00,0xC0,0x3F,0xFF,0xFF,0xFF,
  0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x03,
  0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x03,
  0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x03,
  0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x03,
  0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x03,
  0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x03,
  0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x03,
  0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x03,
  0xC0,0x3F,0xF8,0x07,0xFF,0xFF,0xFE,0x01,0x80,0x7F,0xFF,0xFF,0xE0,0x1F,0xFC,0x03,
  0xC0,0x3F,0xF8,0x07,0xFF,0xFF,0xFE,0x01,0x80,0x7F,0xFF,0xFF,0xE0,0x1F,0xFC,0x03,
  0xC0,0x00,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x00,0x03,
  0xC0,0x00,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x00,0x03,
  0xC0,0x00,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x00,0x03,
  0xC0,0x00,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x00,0x03,
  0xC0,0x00,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x00,0x03,
  0xC0,0x00,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x00,0x03,
  0xC0,0x00,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x00,0x03,
  0xC0,0x00,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x00,0x03,
  0xFF,0xE0,0x1F,0xFC,0x03,0x00,0xFF,0xFF,0xFF,0xFF,0x00,0xC0,0x3F,0xF8,0x07,0xFF,
  0xFF,0xE0,0x1F,0xFC,0x03,0x00,0xFF,0xFF,0xFF,0xFF,0x00,0xC0,0x3F,0xF8,0x07,0xFF,
  0xC0,0x00,0x00,0x00,0x03,0x00,0x00,0x01,0x80,0x00,0x00,0xC0,0x00,0x00,0x00,0x03,
  0xC0,0x00,0x00,0x00,0x03,0x00,0x00,0x01,0x80,0x00,0x00,0xC0,0x00,0x00,0x00,0x03,
  0xC0,0x00,0x00,0x00,0x03,0x00,0x00,0x01,0x80,0x00,0x00,0xC0,0x00,0x00,0x00,0x03,
  0xC0,0x00,0x00,0x00,0x03,0x00,0x00,0x01,0x80,0x00,0x00,0xC0,0x00,0x00,0x00,0x03,
  0xC0,0x00,0x00,0x00,0x03,0x00,0x00,0x01,0x80,0x00,0x00,0xC0,0x00,0x00,0x00,0x03,
  0xC0,0x00,0x00,0x00,0x03,0x00,0x00,0x01,0x80,0x00,0x00,0xC0,0x00,0x00,0x00,0x03,
  0xC0,0x00,0x00,0x00,0x03,0x00,0x00,0x01,0x80,0x00,0x00,0xC0,0x00,0x00,0x00,0x03,
  0xC0,0x00,0x00,0x00,0x03,0x00,0x00,0x01,0x80,0x00,0x00,0xC0,0x00,0x00,0x00,0x03,
  0xC0,0x3F,0xFF,0xFF,0xFF,0xFF,0xFE,0x01,0x80,0x7F,0xFF,0xFF,0xFF,0xFF,0xFC,0x03,
  0xC0,0x3F,0xFF,0xFF,0xFF,0xFF,0xFE,0x01,0x80,0x7F,0xFF,0xFF,0xFF,0xFF,0xFC,0x03,
  0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,
  0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,
  0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,
  0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,
  0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,
  0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,
  0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,
  0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,
  0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x3D,0xEF,0x7B,0xD0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x14,0xBD,0xE8,0x00,
  0x21,0x09,0x4A,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x14,0xA1,0x00,0x00,
  0x3D,0x09,0x7B,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x14,0xB9,0xE0,0x00,
  0x05,0x09,0x52,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x15,0x20,0x20,0x00,
  0x3D,0xEF,0x4B,0xD0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0xD2,0x3D,0xE8,0x00
};


//start 
PROGMEM const unsigned char start[] = {
  128, 64, //pictureresolution
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x03,0xFF,0xFF,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xFF,0xFF,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0xFF,0xFF,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0xFF,0xE7,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0xFF,0xE7,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0xFF,0xFF,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0xFF,0xFF,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0xFF,0xFF,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0x80,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0xFF,0xFF,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0xFF,0xFF,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0xFF,0xFF,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0xFF,0xFF,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0xFF,0xFF,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0xFF,0xFF,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xFF,0xFF,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x03,0xFF,0xFF,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0xF3,0xCF,0x9C,0x70,0x07,0x3E,0x73,0xCF,0x80,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x8A,0x28,0x22,0x88,0x08,0x88,0x8A,0x22,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x8A,0x28,0x20,0x80,0x08,0x08,0x8A,0x22,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0xF3,0xCF,0x1C,0x70,0x07,0x08,0x8B,0xC2,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x82,0x48,0x02,0x08,0x00,0x88,0xFA,0x42,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x82,0x28,0x22,0x88,0x08,0x88,0x8A,0x22,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x82,0x2F,0x9C,0x70,0x07,0x08,0x8A,0x22,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};


//game over 
PROGMEM const unsigned char over[] = {
  128, 64, //pictureresolution
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x0F,0xE0,0x00,0x01,0xFF,0x00,0x07,0xFC,0x00,0x1F,0xF0,0x00,0x7F,0xC0,0x00,
  0x00,0x3F,0xF8,0x00,0x03,0xFF,0x80,0x0F,0xFE,0x00,0x3F,0xF8,0x00,0xFF,0xE0,0x00,
  0x00,0x7F,0xFC,0x00,0x07,0xFF,0xC0,0x1F,0xFF,0x00,0x7F,0xFC,0x01,0xFF,0xF0,0x00,
  0x00,0xFE,0x7E,0x00,0x0F,0xFF,0xE0,0x3F,0xFF,0x80,0xFF,0xFE,0x03,0xFF,0xF8,0x00,
  0x01,0xFE,0x7F,0x00,0x00,0xF8,0x70,0x03,0xE1,0xC0,0x0F,0x87,0x00,0x3E,0x1C,0x00,
  0x00,0x7F,0xFF,0x00,0x1E,0xF7,0x70,0x7B,0xDD,0xC1,0xEF,0x77,0x07,0xBD,0xDC,0x00,
  0x00,0x0F,0xFF,0x80,0x1F,0x77,0xB0,0x7D,0xDE,0xC1,0xF7,0x7B,0x07,0xDD,0xEC,0x00,
  0x00,0x01,0xFF,0x80,0x23,0x71,0xB0,0x8D,0xC6,0xC2,0x37,0x1B,0x08,0xDC,0x6C,0x00,
  0x00,0x00,0x1F,0x80,0x23,0x71,0xB8,0x8D,0xC6,0xE2,0x37,0x1B,0x88,0xDC,0x6E,0x00,
  0x00,0x00,0x1F,0x80,0x23,0x71,0xB8,0x8D,0xC6,0xE2,0x37,0x1B,0x88,0xDC,0x6E,0x00,
  0x00,0x01,0xFF,0x80,0x2E,0xF7,0x78,0xBB,0xDD,0xE2,0xEF,0x77,0x8B,0xBD,0xDE,0x00,
  0x00,0x0F,0xFF,0x80,0x31,0xF8,0xF8,0xC7,0xE3,0xE3,0x1F,0x8F,0x8C,0x7E,0x3E,0x00,
  0x00,0x7F,0xFF,0x80,0x3F,0xFF,0xF8,0xFF,0xFF,0xE3,0xFF,0xFF,0x8F,0xFF,0xFE,0x00,
  0x01,0xFF,0xFF,0x00,0x3F,0xFF,0xF8,0xFF,0xFF,0xE3,0xFF,0xFF,0x8F,0xFF,0xFE,0x00,
  0x01,0xFF,0xFE,0x00,0x3F,0xFF,0xF8,0xFF,0xFF,0xE3,0xFF,0xFF,0x8F,0xFF,0xFE,0x00,
  0x00,0x7F,0xFC,0x00,0x3F,0xFF,0xF8,0xFF,0xFF,0xE3,0xFF,0xFF,0x8F,0xFF,0xFE,0x00,
  0x00,0x1F,0xF8,0x00,0x3F,0xE7,0xF8,0xFF,0x9F,0xE3,0xFE,0x7F,0x8F,0xF9,0xFE,0x00,
  0x00,0x0F,0xE0,0x00,0x39,0xC7,0x98,0xE7,0x1E,0x63,0x9C,0x79,0x8E,0x71,0xE6,0x00,
  0x00,0x00,0x00,0x00,0x20,0xC7,0x08,0x83,0x1C,0x22,0x0C,0x70,0x88,0x31,0xC2,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x03,0x8E,0x45,0xF0,0x0E,0x45,0xF7,0x80,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x04,0x51,0x6D,0x00,0x11,0x45,0x04,0x40,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x04,0x11,0x55,0x00,0x11,0x45,0x04,0x40,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x05,0xD1,0x45,0xE0,0x11,0x45,0xE7,0x80,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x04,0x5F,0x45,0x00,0x11,0x45,0x04,0x80,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x04,0x51,0x45,0x00,0x11,0x29,0x04,0x40,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x03,0xD1,0x45,0xF0,0x0E,0x11,0xF4,0x40,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x3D,0xEF,0x7B,0xD0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x21,0x09,0x4A,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x3D,0x09,0x7B,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x05,0x09,0x52,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x3D,0xEF,0x4B,0xD0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};

//logo
PROGMEM const unsigned char logo[] = {
  128, 32, //pictureresolution
  0x03,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xC0,
  0x1F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xF0,
  0x3E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7C,
  0x70,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1C,
  0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0E,
  0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,
  0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,
  0xC0,0xFF,0xC0,0x00,0x00,0x7F,0x80,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x7F,0x03,
  0xC0,0xFF,0xF0,0x18,0x00,0xFF,0xE0,0x00,0x03,0x00,0x0C,0x03,0x80,0x60,0x7F,0x03,
  0xC0,0xFF,0xF8,0x3C,0x01,0xFF,0xF0,0x00,0x03,0x80,0x1C,0x03,0x80,0x70,0x7F,0x03,
  0xC0,0xFF,0xF8,0x3C,0x03,0xFF,0xF8,0x00,0x03,0xC0,0x3C,0x07,0xC0,0x78,0x7F,0x03,
  0xC0,0xFF,0xFC,0x7E,0x03,0xFF,0xFC,0x00,0x03,0xE0,0x7C,0x07,0xC0,0x7C,0x7F,0x03,
  0xC0,0xFF,0xFC,0x7E,0x07,0xFF,0xF8,0x00,0x03,0xF0,0xFC,0x0F,0xE0,0x7E,0x7F,0x03,
  0xC0,0xFE,0xFC,0xFF,0x07,0xFF,0xC0,0x7F,0x03,0xF8,0xFC,0x0F,0xF0,0x7F,0x7F,0x03,
  0xC0,0xFF,0xFC,0xFF,0x8F,0xFF,0x00,0x7F,0xC3,0xFD,0xFC,0x1F,0xF0,0x7F,0x7F,0x03,
  0xC0,0xFF,0xFD,0xFF,0x8F,0xFE,0x00,0x7F,0xC3,0xFF,0xFC,0x3F,0xF8,0x7F,0xFF,0x03,
  0xC0,0xFF,0xF9,0xFF,0xCF,0xFC,0x00,0x3F,0xC3,0xFF,0xFC,0x3F,0xF8,0x7F,0xFF,0x03,
  0xC0,0xFF,0xFB,0xE7,0xC7,0xFF,0x00,0x3F,0xC3,0xFF,0xFC,0x7E,0x7C,0x7F,0xFF,0x03,
  0xC0,0xFF,0xF3,0xFF,0xE7,0xFF,0xF0,0x00,0x03,0xFF,0xFC,0x7F,0xFC,0x7F,0xFF,0x03,
  0xC0,0xFE,0x07,0xFF,0xE7,0xFF,0xFC,0x00,0x03,0xFF,0xFC,0xFF,0xFE,0x7F,0xFF,0x03,
  0xC0,0xFE,0x07,0xFF,0xE3,0xFF,0xFC,0x00,0x03,0xFF,0xFC,0xFF,0xFE,0x7F,0xFF,0x03,
  0xC0,0xFE,0x0F,0xFF,0xF1,0xFF,0xFC,0x00,0x03,0xFF,0xFC,0xFF,0xFF,0x7F,0xFF,0x03,
  0xC0,0xFE,0x0F,0xFF,0xB9,0xFF,0xF8,0x00,0x03,0xFF,0xDD,0xFF,0xF7,0x3F,0xF7,0x03,
  0xC0,0xFE,0x0F,0xFF,0xB8,0x7F,0xF0,0x00,0x03,0xFF,0xDD,0xFF,0xF7,0xBF,0xF7,0x03,
  0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,
  0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,
  0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,
  0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,
  0x70,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0E,
  0x3E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7C,
  0x1F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xF8,
  0x03,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xC0
};

pitches.h

Arduino
/*************************************************

 * Public Constants

 *************************************************/

#define NOTE_B0  31
#define NOTE_C1  33
#define NOTE_CS1 35
#define NOTE_D1  37
#define NOTE_DS1 39
#define NOTE_E1  41
#define NOTE_F1  44
#define NOTE_FS1 46
#define NOTE_G1  49
#define NOTE_GS1 52
#define NOTE_A1  55
#define NOTE_AS1 58
#define NOTE_B1  62
#define NOTE_C2  65
#define NOTE_CS2 69
#define NOTE_D2  73
#define NOTE_DS2 78
#define NOTE_E2  82
#define NOTE_F2  87
#define NOTE_FS2 93
#define NOTE_G2  98
#define NOTE_GS2 104
#define NOTE_A2  110
#define NOTE_AS2 117
#define NOTE_B2  123
#define NOTE_C3  131
#define NOTE_CS3 139
#define NOTE_D3  147
#define NOTE_DS3 156
#define NOTE_E3  165
#define NOTE_F3  175
#define NOTE_FS3 185
#define NOTE_G3  196
#define NOTE_GS3 208
#define NOTE_A3  220
#define NOTE_AS3 233
#define NOTE_B3  247
#define NOTE_C4  262
#define NOTE_CS4 277
#define NOTE_D4  294
#define NOTE_DS4 311
#define NOTE_E4  330
#define NOTE_F4  349
#define NOTE_FS4 370
#define NOTE_G4  392
#define NOTE_GS4 415
#define NOTE_A4  440
#define NOTE_AS4 466
#define NOTE_B4  494
#define NOTE_C5  523
#define NOTE_CS5 554
#define NOTE_D5  587
#define NOTE_DS5 622
#define NOTE_E5  659
#define NOTE_F5  698
#define NOTE_FS5 740
#define NOTE_G5  784
#define NOTE_GS5 831
#define NOTE_A5  880
#define NOTE_AS5 932
#define NOTE_B5  988
#define NOTE_C6  1047
#define NOTE_CS6 1109
#define NOTE_D6  1175
#define NOTE_DS6 1245
#define NOTE_E6  1319
#define NOTE_F6  1397
#define NOTE_FS6 1480
#define NOTE_G6  1568
#define NOTE_GS6 1661
#define NOTE_A6  1760
#define NOTE_AS6 1865
#define NOTE_B6  1976
#define NOTE_C7  2093
#define NOTE_CS7 2217
#define NOTE_D7  2349
#define NOTE_DS7 2489
#define NOTE_E7  2637
#define NOTE_F7  2794
#define NOTE_FS7 2960
#define NOTE_G7  3136
#define NOTE_GS7 3322
#define NOTE_A7  3520
#define NOTE_AS7 3729
#define NOTE_B7  3951
#define NOTE_C8  4186
#define NOTE_CS8 4435
#define NOTE_D8  4699
#define NOTE_DS8 4978

Credits

giobbino
4 projects • 4 followers
Contact

Comments

Please log in or sign up to comment.