Devices & Components
Arduino Uno Rev3
Breadboard (generic)
LED Dot Matrix Display, Red
Jumper wires (generic)
Project description
Code
CREATE YOUR OWN SHAPE 8x8 LED Matrix
c_cpp
1// 2-dimensional array of row pin numbers: 2const int row[8] = { 3 2, 7, 19, 5, 13, 18, 12, 16 4}; 5 6// 2-dimensional array of column pin numbers: 7const int col[8] = { 8 6, 11, 10, 3, 17, 4, 8, 9 9}; 10 11// 2-dimensional array of pixels: 12int pixels[8][8]; 13 14typedef bool charMapType[8][8]; 15 16const charMapType heart = { 17 {0, 0, 0, 0, 0, 0, 0, 0}, 18 {0, 1, 1, 0, 0, 1, 1, 0}, 19 {1, 1, 1, 1, 1, 1, 1, 1}, 20 {1, 1, 1, 1, 1, 1, 1, 1}, 21 {0, 1, 1, 1, 1, 1, 1, 0}, 22 {0, 0, 1, 1, 1, 1, 0, 0}, 23 {0, 0, 0, 1, 1, 0, 0, 0}, 24 {0, 0, 0, 0, 0, 0, 0, 0} 25}; 26 27// angry robot 28// const charMapType angryRobot = { 29// {1, 1, 1, 1, 1, 1, 1, 1}, 30// {1, 0, 1, 1, 1, 1, 0, 1}, 31// {1, 0, 0, 1, 1, 0, 0, 1}, 32// {1, 1, 1, 1, 1, 1, 1, 1}, 33// {1, 1, 0, 1, 1, 0, 1, 1}, 34// {1, 0, 0, 0, 0, 0, 0, 1}, 35// {1, 1, 1, 0, 0, 1, 1, 1}, 36// {1, 1, 1, 1, 1, 1, 1, 1} 37// }; 38 39//squares 40// const charMapType squares = { 41// {1, 1, 1, 1, 1, 1, 1, 1}, 42// {1, 0, 0, 0, 0, 0, 0, 1}, 43// {1, 0, 1, 1, 1, 1, 0, 1}, 44// {1, 0, 1, 0, 0, 1, 0, 1}, 45// {1, 0, 1, 0, 0, 1, 0, 1}, 46// {1, 0, 1, 1, 1, 1, 0, 1}, 47// {1, 0, 0, 0, 0, 0, 0, 1}, 48// {1, 1, 1, 1, 1, 1, 1, 1} 49// }; 50 51void setup() { 52 for (int thisPin = 0; thisPin < 8; thisPin++) { 53 pinMode(col[thisPin], OUTPUT); 54 pinMode(row[thisPin], OUTPUT); 55 } 56 setupMatrix(); 57} 58 59void loop() { 60 displayLedPattern(); 61} 62 63void displayLedPattern(){ 64 for (int thisRow = 0; thisRow < 8; thisRow++) { 65 digitalWrite(row[thisRow], HIGH); 66 for (int thisCol = 0; thisCol < 8; thisCol++) { 67 // get the state of the current pixel; 68 int thisPixel = pixels[thisRow][thisCol]; 69 // when the row is HIGH and the col is LOW, 70 // the LED where they meet turns on: 71 digitalWrite(col[thisCol], thisPixel); 72 // turn the pixel off: 73 if (thisPixel == LOW) { 74 digitalWrite(col[thisCol], HIGH); 75 } 76 } 77 // take the row pin low to turn off the whole row: 78 digitalWrite(row[thisRow], LOW); 79 } 80} 81 82void setupMatrix(){ 83 for (int x = 0; x < 8; x++) { 84 for (int y = 0; y < 8; y++) { 85 bool v = squares[x][y]; 86 if(v){ 87 pixels[x][y] = LOW; 88 }else{ 89 pixels[x][y] = HIGH; 90 } 91 } 92 } 93}
Downloadable files
8x8 LED Matrix
The knob is at the bottom. which means pins 1-8 are there.
8x8 LED Matrix

Comments
Only logged in users can leave comments