Advertisement
Guest User

Arduino Sketch

a guest
Jan 29th, 2013
496
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.43 KB | None | 0 0
  1. //delay time
  2. int delay1 = 5;
  3. //count to determine the number of rows to draw
  4. int count = 0;
  5. //width of array
  6. int width = 57;
  7.  
  8. //matrix of values to draw
  9. int ledarray[8][57]={
  10. {0,1,0,0,1,0,1,1,1,0,1,0,0,0,1,0,0,0,0,1,1,0,0,0,0,0,1,0,0,0,1,0,0,1,1,0,0,1,1,1,0,0,1,0,0,0,1,1,1,0,0,0,0,0,0,0,0},
  11. {0,1,0,0,1,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,1,0,0,0,0,1,0,0,0,1,0,1,0,0,1,0,1,0,0,1,0,1,0,0,0,1,0,0,1,0,0,0,0,0,0,0},
  12. {0,1,0,0,1,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,1,0,0,0,0,1,0,0,0,1,0,1,0,0,1,0,1,0,0,1,0,1,0,0,0,1,0,0,1,0,0,0,0,0,0,0},
  13. {0,1,0,0,1,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,1,0,0,0,0,1,0,0,0,1,0,1,0,0,1,0,1,0,0,1,0,1,0,0,0,1,0,0,1,0,0,0,0,0,0,0},
  14. {0,1,1,1,1,0,1,1,0,0,1,0,0,0,1,0,0,0,1,0,0,1,0,0,0,0,1,0,0,0,1,0,1,0,0,1,0,1,1,1,0,0,1,0,0,0,1,0,0,1,0,0,0,0,0,0,0},
  15. {0,1,0,0,1,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,1,0,0,0,0,1,0,1,0,1,0,1,0,0,1,0,1,0,1,0,0,1,0,0,0,1,0,0,1,0,0,0,0,0,0,0},
  16. {0,1,0,0,1,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,1,0,0,0,0,1,1,0,1,1,0,1,0,0,1,0,1,0,0,1,0,1,0,0,0,1,0,0,1,0,0,0,0,0,0,0},
  17. {0,1,0,0,1,0,1,1,1,0,1,1,1,0,1,1,1,0,0,1,1,0,0,0,0,0,1,0,0,0,1,0,0,1,1,0,0,1,0,0,1,0,1,1,1,0,1,1,1,0,0,0,0,0,0,0,0}
  18. //1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0, numbers for reference of width
  19. };
  20.  
  21. void setup()
  22. {
  23. //initialise all the pins used for LEDs as outputs
  24. for (int pincount = 1; pincount < 9; pincount++)
  25. {
  26. pinMode(pincount, OUTPUT);
  27. }
  28. }
  29.  
  30. //loop runs over and over after setup
  31. void loop()
  32. {
  33.  
  34. if(count == width) //if the whole array has been drawn
  35. {
  36. count = 0; //reset and draw again
  37. }
  38. else
  39. {
  40. flash(count); //else draw the next row
  41. count++; //and increment count
  42. }
  43. delay(delay1); //delay between LED flashes
  44. }
  45.  
  46. void alloff () //method to turn all LED's off, never used
  47. {
  48. for (int pincount1 = 1; pincount1 < 9; pincount1++)
  49. {
  50. digitalWrite(pincount1, LOW);
  51. }
  52. }
  53.  
  54. void allon () //method to turn all LED's on, never used
  55. {
  56. for (int pincount2 = 1; pincount2 < 9; pincount2++)
  57. {
  58. digitalWrite(pincount2, HIGH);
  59. }
  60. }
  61.  
  62. void flash (int row) //fairly simple method to flash a row of LED's
  63. {
  64. for (int count1 = 1; count1 < 9; count1++)
  65. if (ledarray[count1-1][row] == 1)
  66. {
  67. digitalWrite(count1, HIGH); //if the array states to, turn the Nth LED on
  68. }
  69. else
  70. {
  71. digitalWrite(count1, LOW); //if the array states to, turn the Nth LED on
  72. }
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement