Difference between revisions of "Adafruit: 8x8 Yellow LED Matrix Panel"

From eLinux.org
Jump to: navigation, search
m (Overview)
 
(6 intermediate revisions by one other user not shown)
Line 3: Line 3:
  
 
== Overview ==
 
== Overview ==
 +
 +
<pre style="color:red">
 +
 +
Overview: 2
 +
Wiring:  2, nice clear picture
 +
Code:    2, nice animation
 +
git/Compiles with make: 2  make works
 +
Demo:    2
 +
Total:    10
 +
Comments: Looks good. Maybe you could post a video to YouTube and put a link here.
 +
</pre>
  
 
The adafriut 8*8 yellow Led matrix has been used in my mini project 2. I'm using it to display some simple pattern, Chinese characters and even some simple animation.
 
The adafriut 8*8 yellow Led matrix has been used in my mini project 2. I'm using it to display some simple pattern, Chinese characters and even some simple animation.
Line 47: Line 58:
 
</pre>
 
</pre>
  
Here is the codes in file:
+
The codes for the whole project can be found in my github: [https://github.com/xinyu1991/Mini-Project-2 Codes for Mini Project 2].
  
<pre>
+
== Demo Pictures of Display ==
#include <errno.h>#include <string.h>#include <stdio.h>#include <stdlib.h>#include <unistd.h>#include "i2c-dev.h"#include "i2cbusses.h"#include "MatrixLed.h"int main(int argc, char *argv[]){ int res, i2cbus, address, size, file; int value, daddress; char filename[20]; int force = 0, readback = 1; int len; i2cbus = lookup_i2c_bus("3"); printf("i2cbus = %d\n", i2cbus); if (i2cbus < 0) help(); address = parse_i2c_address("0x70"); printf("address = 0x%2x\n", address); if (address < 0) help(); size = I2C_SMBUS_BYTE; daddress = 0x21; if (daddress < 0 || daddress > 0xff) { fprintf(stderr, "Error: Data address invalid!\n"); help(); } file = open_i2c_dev(i2cbus, filename, sizeof(filename), 0); printf("file = %d\n", file); if (file < 0 || check_funcs(file, size) || set_slave_addr(file, address, force)) exit(1); switch (size) { case I2C_SMBUS_BYTE: daddress = 0x21; // Start oscillator (page 10) printf("writing: 0x%02x\n", daddress); res = i2c_smbus_write_byte(file, daddress); daddress = 0x81; // Display on, blinking off (page 11) printf("writing: 0x%02x\n", daddress); res = i2c_smbus_write_byte(file, daddress); daddress = 0xe7; // Full brightness (page 15) printf("writing: 0x%02x\n", daddress); res = i2c_smbus_write_byte(file, daddress); daddress = 0x00; // Start writing to address 0 (page 13) printf("writing: 0x%02x\n", daddress); res = i2c_smbus_write_byte(file, daddress); int i;                while(1)                {                    //Display the Square.                        display(Square1_bmp,res,daddress,file);                  display(Square2_bmp,res,daddress,file);                  display(Square3_bmp,res,daddress,file);                  display(Square4_bmp,res,daddress,file);                  display(Square5_bmp,res,daddress,file);                  display(Square6_bmp,res,daddress,file);                  display(Square7_bmp,res,daddress,file);                  //Display Love Heart.                   display(Love1_bmp,res,daddress,file);                  display(Love2_bmp,res,daddress,file);                  display(Love1_bmp,res,daddress,file);                  //Display I love U.                   display(I_bmp,res,daddress,file);                  display(Love1_bmp,res,daddress,file);                                    display(U_bmp,res,daddress,file);                                    //Display the Square.                   display(Square7_bmp,res,daddress,file);                  display(Square6_bmp,res,daddress,file);                  display(Square5_bmp,res,daddress,file);                  display(Square4_bmp,res,daddress,file);                  display(Square3_bmp,res,daddress,file);                  display(Square2_bmp,res,daddress,file);                  display(Square1_bmp,res,daddress,file);                                      //Display Love Heart.                   display(Love1_bmp,res,daddress,file);                  display(Love2_bmp,res,daddress,file);                  display(Love1_bmp,res,daddress,file);                          } break; case I2C_SMBUS_WORD_DATA: res = i2c_smbus_write_word_data(file, daddress, value); break; case I2C_SMBUS_BLOCK_DATA: res = i2c_smbus_write_block_data(file, daddress, len, (const __u8 *)block); break; case I2C_SMBUS_I2C_BLOCK_DATA: res = i2c_smbus_write_i2c_block_data(file, daddress, len, (const __u8 *)block); break; default: /* I2C_SMBUS_BYTE_DATA */ res = i2c_smbus_write_byte_data(file, daddress, value); break; } if (res < 0) { fprintf(stderr, "Error: Write failed\n"); close(file); exit(1); } if (!readback) { /* We're done */ close(file); exit(0); } switch (size) { case I2C_SMBUS_BYTE: res = i2c_smbus_read_byte(file); value = daddress; break; case I2C_SMBUS_WORD_DATA: res = i2c_smbus_read_word_data(file, daddress); break; default: /* I2C_SMBUS_BYTE_DATA */ res = i2c_smbus_read_byte_data(file, daddress); } close(file); if (res < 0) { printf("Warning - readback failed\n"); } else if (res != value) { printf("Warning - data mismatch - wrote "       "0x%0*x, read back 0x%0*x\n",       size == I2C_SMBUS_WORD_DATA ? 4 : 2, value,       size == I2C_SMBUS_WORD_DATA ? 4 : 2, res); } else { printf("Value 0x%0*x written, readback matched\n",       size == I2C_SMBUS_WORD_DATA ? 4 : 2, value); } exit(0);}
+
 
</pre>
+
I desired to upload a video here. However the file type is prohibited. So, the only method I can show my work here is through the pictures:
 +
 
 +
[[File:The Matrix Display I.JPG]]
 +
 
 +
[[File:The Matrix Display Love.JPG]]
 +
 
 +
[[File:The Martix Display U.JPG]]
 +
 
 +
That's my introduce to the Led Matrix. Hope you can have an enjoy experience while using the device.

Latest revision as of 20:18, 17 October 2012


Overview


Overview: 2
Wiring:   2, nice clear picture
Code:     2, nice animation
git/Compiles with make: 2  make works
Demo:     2
Total:    10
Comments: Looks good. Maybe you could post a video to YouTube and put a link here.

The adafriut 8*8 yellow Led matrix has been used in my mini project 2. I'm using it to display some simple pattern, Chinese characters and even some simple animation.

The code of the project is modified from the sample code provided by Dr. Yoder. And my code has been commited to my github: The github repository of Xinyu Cheng.

Here is a display sample of the Led Matrix:

Display Sample.JPG

Hardware Connection

To ensure the matrix works properly, we need to connect the four pins in the device to the Beagle Bone. Here is a picture for the connection:

Hardware Connection.jpg

As we can see in the picture, the VCC and GND are connected to the VCC and GND in the Bone. And the data pin is connected Pin D18, which is I2C2_SDA. Connect the clock pin to Pin D17, which is I2C2_SCL. After the above connection, the hardware part is done.

Software Design

The mainly work of the software here is to display the correct pattern. And the pattern can be depicted through write a correct value (1 or 0) to each LED in the matrix. 1 means the LED is on and 0 means the LED is off.

For example, the pattern of ❤ can be displayed through the array:

Heart_bmp[]={0x0C, 0x1E, 0x3E, 0x7C, 0x3E, 0x1E, 0x0C, 0x00};

I have write a function to implement the display:

//The Function to Display a BMP.
int display(__u16 bmp[], int res, int daddress, int file)
{     
    int i;     
    for(i=0; i<8; i++)      
    {	block[i] = (bmp[i]&0xfe) >>1 |  
        (bmp[i]&0x01) << 7;     
    }     

    res = i2c_smbus_write_i2c_block_data(file, daddress, 16, 	   
    (__u8 *)block);     

    usleep(400000);
}

The codes for the whole project can be found in my github: Codes for Mini Project 2.

Demo Pictures of Display

I desired to upload a video here. However the file type is prohibited. So, the only method I can show my work here is through the pictures:

The Matrix Display I.JPG

The Matrix Display Love.JPG

The Martix Display U.JPG

That's my introduce to the Led Matrix. Hope you can have an enjoy experience while using the device.