Printoo Man

Printoo Man

Material Required

  • Printoo Core
  • LED Matrix (8×8) Display
  • Coin Cell Battery Holder

Schematic

Schematic: Printoo Man

Schematic: Printoo Man

Code

Download from GitHub

  1. /**********************************************************************
  2. * © 2014 YD Ynvisible, S.A.
  3. *
  4. * FileName:        Printoo_Man.ino
  5. * Dependencies:    -
  6. * Processor:       ATmega328
  7. * IDE:             Arduino 1.0.5
  8. *
  9. * Description:
  10. * Animated 8x8 led matrix forming a face
  11. *
  12. **********************************************************************/
  13.  
  14. //MATRIX PINS
  15. //Pin connected to ST_CP of 74LV595
  16. int latchPin = 9;
  17. //Pin connected to SH_CP of 74LV595
  18. int clockPin = 11;
  19. //Pin connected to DS of 74LV595
  20. int dataPin = 8;
  21. //Pin connected to EN of 74LV595
  22. int enPin = 13;
  23. //Pin connected to the Regulator enable
  24. int enRegPin = 12;
  25.  
  26. void configure_timers(void);               //using timers!
  27. // **** DISPLAYS *****
  28.  
  29. int counter = 1;
  30. boolean toggle1 = 0;
  31.  
  32. int LEDs_off[8][8] = {  
  33.   {0, 0, 0, 0, 0, 0, 0, 0},
  34.   {0, 0, 0, 0, 0, 0, 0, 0},
  35.   {0, 0, 0, 0, 0, 0, 0, 0},
  36.   {0, 0, 0, 0, 0, 0, 0, 0},
  37.   {0, 0, 0, 0, 0, 0, 0, 0},
  38.   {0, 0, 0, 0, 0, 0, 0, 0},
  39.   {0, 0, 0, 0, 0, 0, 0, 0},
  40.   {0, 0, 0, 0, 0, 0, 0, 0}      
  41. };
  42.  
  43. int face_1[8][8] = {        
  44.   {0, 0, 0, 0, 0, 0, 0, 0},
  45.   {0, 0, 0, 0, 0, 0, 0, 0},
  46.   {0, 1, 1, 0, 0, 1, 1, 0},
  47.   {0, 0, 0, 0, 0, 0, 0, 0},
  48.   {0, 0, 0, 0, 0, 0, 0, 0},
  49.   {0, 0, 0, 0, 0, 0, 0, 0},
  50.   {0, 1, 1, 1, 1, 1, 1, 0},
  51.   {0, 0, 0, 0, 0, 0, 0, 0}      
  52. };
  53.  
  54. int face_2[8][8] = {        
  55.   {0, 0, 0, 0, 0, 0, 0, 0},
  56.   {0, 1, 1, 0, 0, 1, 1, 0},
  57.   {0, 1, 1, 0, 0, 1, 1, 0},
  58.   {0, 0, 0, 0, 0, 0, 0, 0},
  59.   {0, 0, 0, 0, 0, 0, 0, 0},
  60.   {0, 0, 0, 0, 0, 0, 0, 0},
  61.   {0, 1, 1, 1, 1, 1, 1, 0},
  62.   {0, 0, 0, 0, 0, 0, 0, 0}      
  63. };
  64.  
  65. int face_3[8][8] = {      
  66.   {0, 0, 0, 0, 0, 0, 0, 0},
  67.   {0, 1, 1, 0, 0, 1, 1, 0},
  68.   {0, 1, 1, 0, 0, 1, 1, 0},
  69.   {0, 0, 0, 0, 0, 0, 0, 0},
  70.   {0, 0, 0, 0, 0, 0, 0, 0},
  71.   {0, 1, 0, 0, 0, 0, 1, 0},
  72.   {0, 0, 1, 1, 1, 1, 0, 0},
  73.   {0, 0, 0, 0, 0, 0, 0, 0}      
  74. };
  75.  
  76. int face_4[8][8] = {        
  77.   {0, 0, 0, 0, 0, 0, 0, 0},
  78.   {0, 1, 1, 0, 0, 1, 1, 0},
  79.   {0, 1, 1, 0, 0, 1, 1, 0},
  80.   {0, 0, 0, 0, 0, 0, 0, 0},
  81.   {0, 0, 0, 0, 0, 0, 0, 0},
  82.   {0, 1, 1, 1, 1, 1, 1, 0},
  83.   {0, 0, 1, 1, 1, 1, 0, 0},
  84.   {0, 0, 0, 0, 0, 0, 0, 0}      
  85. };
  86.  
  87. int face_5[8][8] = {    
  88.   {0, 0, 0, 0, 0, 0, 0, 0},
  89.   {0, 1, 1, 0, 0, 1, 1, 0},
  90.   {0, 1, 1, 0, 0, 1, 1, 0},
  91.   {0, 0, 0, 0, 0, 0, 0, 0},
  92.   {0, 1, 1, 1, 1, 1, 1, 0},
  93.   {0, 1, 0, 0, 0, 0, 1, 0},
  94.   {0, 0, 1, 1, 1, 1, 0, 0},
  95.   {0, 0, 0, 0, 0, 0, 0, 0}      
  96. };
  97.  
  98. int face_6[8][8] = {  
  99.   {0, 0, 0, 0, 0, 0, 0, 0},
  100.   {0, 0, 0, 0, 0, 0, 0, 0},
  101.   {0, 1, 1, 0, 0, 1, 1, 0},
  102.   {0, 0, 0, 0, 0, 0, 0, 0},
  103.   {0, 1, 1, 1, 1, 1, 1, 0},
  104.   {0, 1, 0, 0, 0, 0, 1, 0},
  105.   {0, 0, 1, 1, 1, 1, 0, 0},
  106.   {0, 0, 0, 0, 0, 0, 0, 0}      
  107. };
  108.  
  109.  
  110. ISR(TIMER1_COMPA_vect){
  111.  //generates pulse wave of frequency = X Hz
  112.   counter++;
  113. }
  114.  
  115. void setup() {
  116.   //set pins to output because they are addressed in the main loop
  117.   configure_timers();
  118.   pinMode(latchPin, OUTPUT);
  119.   pinMode(clockPin, OUTPUT);
  120.   pinMode(dataPin, OUTPUT);
  121.   pinMode(enPin, OUTPUT);
  122.   pinMode(enRegPin, OUTPUT);
  123.  
  124.   digitalWrite(enRegPin, LOW);  
  125.   digitalWrite(enRegPin, HIGH);
  126. }
  127.  
  128. void loop() {
  129.  
  130.   //ANIMATIONS!!!!!!!!!!!!!!!!!!!!
  131.   if(counter<500){
  132.     lightLED(face_1);
  133.   }
  134.   if(counter>=500&&counter<550){
  135.     lightLED(face_2);
  136.   }
  137.   if(counter>=550&&counter<1050){
  138.     lightLED(face_3);
  139.   }
  140.   if(counter>=1050&&counter<1100){
  141.     lightLED(face_4);
  142.   }
  143.   if(counter>=1100&&counter<1600){
  144.     lightLED(face_5);
  145.   }
  146.   if(counter>=1600&&counter<1700){
  147.     lightLED(face_6);
  148.   }
  149.   if(counter>=1700&&counter<1750){
  150.     lightLED(face_5);
  151.   }
  152.   if(counter>=1750&&counter<1800){
  153.     lightLED(face_6);
  154.   }
  155.   if(counter>=1800&&counter<2800){
  156.     lightLED(face_5);
  157.   }
  158.   if(counter>=2800&&counter<3000){
  159.     lightLED(face_4);
  160.   }
  161.   if(counter>=3000&&counter<3200){
  162.     lightLED(face_3);
  163.   }
  164.   if(counter>=3200&&counter<3400){
  165.     lightLED(face_2);
  166.   }
  167.   if(counter>=3400&&counter<3600){
  168.     lightLED(face_1);
  169.   }
  170.   if(counter>=3600&&counter<5000){
  171.     lightLED(face_1);
  172.   }  
  173.   if(counter>=5000){
  174.     counter=1;
  175.   }
  176.  
  177. }
  178.  
  179. //Lighting the 8x8 Matrix function
  180. void lightLED(int tempLED[8][8]) {
  181.   byte columnbitsToSend = 0;
  182.   byte rowbitsToSend = 0;
  183.  
  184.   int x = 0;
  185.   int y = 0;
  186.   for (x = 0; x < 8; x++) {
  187.     columnbitsToSend = 0;
  188.     rowbitsToSend = 0;
  189.      
  190.     for (y = 0; y < 8; y ++) {
  191.       if (tempLED[y][x] == 0) {   //change to tempLED[x][y] to rotate clockwise
  192.         bitWrite(rowbitsToSend, y, HIGH);
  193.       }
  194.     }
  195.    
  196.     digitalWrite(latchPin, LOW);
  197.     bitWrite(columnbitsToSend, x, HIGH);
  198.     shiftOut(dataPin, clockPin, MSBFIRST, columnbitsToSend);
  199.     shiftOut(dataPin, clockPin, MSBFIRST, rowbitsToSend);
  200.     digitalWrite(latchPin, HIGH);  
  201.     delay(2);
  202.   }
  203. }
  204.  
  205. void configure_timers(){
  206.   cli();//stop interrupts
  207.   //set timer1 interrupt at X Hz
  208.   TCCR1A = 0;// set entire TCCR1A register to 0
  209.   TCCR1B = 0;// same for TCCR1B
  210.   TCNT1  = 0;//initialize counter value to 0
  211.   // set compare match register for 1hz increments
  212.   OCR1A = 14;// = (8*10^6) / (0.2*1024) - 1 (must be <65536)
  213.   // turn on CTC mode
  214.   TCCR1B |= (1 << WGM12);
  215.   // Set CS10 and CS12 bits for 1024 prescaler
  216.   TCCR1B |= (1 << CS12) | (1 << CS10);  
  217.   // enable timer compare interrupt
  218.   TIMSK1 |= (1 << OCIE1A);
  219.   sei();//allow interrupts
  220. }
  221.  
  222. //END
/**********************************************************************
* © 2014 YD Ynvisible, S.A.
*
* FileName:        Printoo_Man.ino
* Dependencies:    -
* Processor:       ATmega328
* IDE:             Arduino 1.0.5
*
* Description:
* Animated 8x8 led matrix forming a face
* 
**********************************************************************/
//MATRIX PINS
//Pin connected to ST_CP of 74LV595
int latchPin = 9;
//Pin connected to SH_CP of 74LV595
int clockPin = 11;
//Pin connected to DS of 74LV595
int dataPin = 8;
//Pin connected to EN of 74LV595
int enPin = 13;
//Pin connected to the Regulator enable
int enRegPin = 12;
void configure_timers(void);               //using timers!
// **** DISPLAYS ***** 
int counter = 1;
boolean toggle1 = 0;
int LEDs_off[8][8] = {   
  {0, 0, 0, 0, 0, 0, 0, 0},
  {0, 0, 0, 0, 0, 0, 0, 0},
  {0, 0, 0, 0, 0, 0, 0, 0},
  {0, 0, 0, 0, 0, 0, 0, 0},
  {0, 0, 0, 0, 0, 0, 0, 0},
  {0, 0, 0, 0, 0, 0, 0, 0},
  {0, 0, 0, 0, 0, 0, 0, 0},
  {0, 0, 0, 0, 0, 0, 0, 0}      
};
int face_1[8][8] = {        
  {0, 0, 0, 0, 0, 0, 0, 0},
  {0, 0, 0, 0, 0, 0, 0, 0},
  {0, 1, 1, 0, 0, 1, 1, 0},
  {0, 0, 0, 0, 0, 0, 0, 0},
  {0, 0, 0, 0, 0, 0, 0, 0},
  {0, 0, 0, 0, 0, 0, 0, 0},
  {0, 1, 1, 1, 1, 1, 1, 0},
  {0, 0, 0, 0, 0, 0, 0, 0}      
};
int face_2[8][8] = {         
  {0, 0, 0, 0, 0, 0, 0, 0},
  {0, 1, 1, 0, 0, 1, 1, 0},
  {0, 1, 1, 0, 0, 1, 1, 0},
  {0, 0, 0, 0, 0, 0, 0, 0},
  {0, 0, 0, 0, 0, 0, 0, 0},
  {0, 0, 0, 0, 0, 0, 0, 0},
  {0, 1, 1, 1, 1, 1, 1, 0},
  {0, 0, 0, 0, 0, 0, 0, 0}      
};
int face_3[8][8] = {      
  {0, 0, 0, 0, 0, 0, 0, 0},
  {0, 1, 1, 0, 0, 1, 1, 0},
  {0, 1, 1, 0, 0, 1, 1, 0},
  {0, 0, 0, 0, 0, 0, 0, 0},
  {0, 0, 0, 0, 0, 0, 0, 0},
  {0, 1, 0, 0, 0, 0, 1, 0},
  {0, 0, 1, 1, 1, 1, 0, 0},
  {0, 0, 0, 0, 0, 0, 0, 0}      
};
int face_4[8][8] = {        
  {0, 0, 0, 0, 0, 0, 0, 0},
  {0, 1, 1, 0, 0, 1, 1, 0},
  {0, 1, 1, 0, 0, 1, 1, 0},
  {0, 0, 0, 0, 0, 0, 0, 0},
  {0, 0, 0, 0, 0, 0, 0, 0},
  {0, 1, 1, 1, 1, 1, 1, 0},
  {0, 0, 1, 1, 1, 1, 0, 0},
  {0, 0, 0, 0, 0, 0, 0, 0}      
};
int face_5[8][8] = {     
  {0, 0, 0, 0, 0, 0, 0, 0},
  {0, 1, 1, 0, 0, 1, 1, 0},
  {0, 1, 1, 0, 0, 1, 1, 0},
  {0, 0, 0, 0, 0, 0, 0, 0},
  {0, 1, 1, 1, 1, 1, 1, 0},
  {0, 1, 0, 0, 0, 0, 1, 0},
  {0, 0, 1, 1, 1, 1, 0, 0},
  {0, 0, 0, 0, 0, 0, 0, 0}      
};
int face_6[8][8] = {   
  {0, 0, 0, 0, 0, 0, 0, 0},
  {0, 0, 0, 0, 0, 0, 0, 0},
  {0, 1, 1, 0, 0, 1, 1, 0},
  {0, 0, 0, 0, 0, 0, 0, 0},
  {0, 1, 1, 1, 1, 1, 1, 0},
  {0, 1, 0, 0, 0, 0, 1, 0},
  {0, 0, 1, 1, 1, 1, 0, 0},
  {0, 0, 0, 0, 0, 0, 0, 0}      
};
ISR(TIMER1_COMPA_vect){
 //generates pulse wave of frequency = X Hz 
  counter++;
}
void setup() {
  //set pins to output because they are addressed in the main loop
  configure_timers();
  pinMode(latchPin, OUTPUT);
  pinMode(clockPin, OUTPUT);
  pinMode(dataPin, OUTPUT);
  pinMode(enPin, OUTPUT);
  pinMode(enRegPin, OUTPUT);
  digitalWrite(enRegPin, LOW);  
  digitalWrite(enRegPin, HIGH);
}
void loop() {
  //ANIMATIONS!!!!!!!!!!!!!!!!!!!!
  if(counter<500){
    lightLED(face_1);
  }
  if(counter>=500&&counter<550){
    lightLED(face_2);
  }
  if(counter>=550&&counter<1050){
    lightLED(face_3);
  }
  if(counter>=1050&&counter<1100){
    lightLED(face_4);
  }
  if(counter>=1100&&counter<1600){
    lightLED(face_5);
  }
  if(counter>=1600&&counter<1700){
    lightLED(face_6);
  }
  if(counter>=1700&&counter<1750){
    lightLED(face_5);
  }
  if(counter>=1750&&counter<1800){
    lightLED(face_6);
  }
  if(counter>=1800&&counter<2800){
    lightLED(face_5);
  }
  if(counter>=2800&&counter<3000){
    lightLED(face_4);
  }
  if(counter>=3000&&counter<3200){
    lightLED(face_3);
  }
  if(counter>=3200&&counter<3400){
    lightLED(face_2);
  }
  if(counter>=3400&&counter<3600){
    lightLED(face_1);
  }
  if(counter>=3600&&counter<5000){
    lightLED(face_1);
  }  
  if(counter>=5000){
    counter=1;
  } 
}
//Lighting the 8x8 Matrix function
void lightLED(int tempLED[8][8]) {
  byte columnbitsToSend = 0;
  byte rowbitsToSend = 0;
  int x = 0;
  int y = 0;
  for (x = 0; x < 8; x++) {
    columnbitsToSend = 0;
    rowbitsToSend = 0;
    for (y = 0; y < 8; y ++) {
      if (tempLED[y][x] == 0) {   //change to tempLED[x][y] to rotate clockwise
        bitWrite(rowbitsToSend, y, HIGH);
      } 
    }
    digitalWrite(latchPin, LOW);
    bitWrite(columnbitsToSend, x, HIGH);
    shiftOut(dataPin, clockPin, MSBFIRST, columnbitsToSend);
    shiftOut(dataPin, clockPin, MSBFIRST, rowbitsToSend);
    digitalWrite(latchPin, HIGH);   
    delay(2);
  }
}
void configure_timers(){
  cli();//stop interrupts
  //set timer1 interrupt at X Hz
  TCCR1A = 0;// set entire TCCR1A register to 0
  TCCR1B = 0;// same for TCCR1B
  TCNT1  = 0;//initialize counter value to 0
  // set compare match register for 1hz increments
  OCR1A = 14;// = (8*10^6) / (0.2*1024) - 1 (must be <65536)
  // turn on CTC mode
  TCCR1B |= (1 << WGM12);
  // Set CS10 and CS12 bits for 1024 prescaler
  TCCR1B |= (1 << CS12) | (1 << CS10);  
  // enable timer compare interrupt
  TIMSK1 |= (1 << OCIE1A);
  sei();//allow interrupts
}
//END