1 /* Arduino Projects for Dummies
4 * Chapter 6: Making a Scrolling Sign
5 * Creates sprites and text messages using an
6 * 8x8 LED matrix display
8 * This sketch just draws a smiley face on the display.
11 * Adapted from Oomlout.com http://www.tinyurl.com/yhwxv6h
14 // Arduino Pin Definitions
15 int rowPin[] = {2,3,4,5,6,7,8,9}; // An Array defining which Arduino pin each row is attached to
16 // (The rows are common anode (driven HIGH))
17 int colPin[] = {17,16,15,14,13,12,11,10}; // An Array defining which pin each column is attached to
18 // (The columns are common cathode (driven LOW))
19 byte smile[] = { // The array used to hold a bitmap of the display
32 for(int i = 0; i <8; i++){ // Set the 16 pins used to control the array to be OUTPUTs
33 pinMode(rowPin[i], OUTPUT); // These correspond to the Arduino pins stored in the arrays
34 pinMode(colPin[i], OUTPUT);
40 displaySprite(); // Display the Sprite
44 for(int count = 0; count < 8; count++){ // A utility counter
45 for(int i = 0; i < 8; i++){
46 digitalWrite(rowPin[i], LOW); // Turn off all row pins
48 for(int i = 0; i < 8; i++){ // Activate only the Arduino pin of the column to light up
50 digitalWrite(colPin[i], LOW); // Setting this LOW connects the current column's cathode to ground
53 digitalWrite(colPin[i], HIGH); // Setting HIGH Turns all the other rows off
56 for(int row = 0; row < 8; row++){ // Iterate through each pixel in the current column
57 int bit = (smile[count] >> row) & 1; // Use a bit shift in the data[] array to do a bitwise comparison
58 // And assign the result of the comparison to the bit
59 if(bit == 1){ // If the bitwise comparison is 1,
60 digitalWrite(rowPin[row], HIGH); // Then light up the LED