Kênh Tên Miền chuyên cung cấp tên miền đẹp, giá rẻ! Hãy liên hệ kỹ thuật: 0914205579 - Kinh doanh: 0912191357 để được tư vấn, hướng dẫn miễn phí, Cảm ơn quý khách đã ủng hộ trong thời gian qua!
Sunday, February 16, 2014

Bài viết này sẽ hướng dẫn làm mạch chạy chữ dùng 7 LED matrix 8x8 sử dụng PIC16F628A , thanh ghi dịch SN74HC164N 8 bit vào nối tiếp ra song song ,và bộ chia 3 kênh thành 8 kênh DSN74HC138N

http://phanhoangthach.blogspot.com/2013/06/ieu-khien-tu-xa-cho-quat-may.html )

Sơ đồ mạch nguyên lý :

 Code lập trình C của mạch này như sau :

#include <16F628A.h>
#FUSES NOWDT                    //No Watch Dog Timer
#FUSES HS                       //High speed Osc (> 4mhz for PCM/PCH) (>10mhz for PCD)
#FUSES NOPUT                    //No Power Up Timer
#FUSES NOPROTECT                //Code not protected from reading
#FUSES NOBROWNOUT               //No brownout reset
#FUSES MCLR                     //Master Clear pin enabled
#FUSES NOLVP                    //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOCPD                    //No EE protection
#FUSES RESERVED                 //Used to set the reserved FUSE bits
#use delay(clock=20000000)
const char ky_tu []={"Phan Hoang Thach     Phan Hoa"};
const char font_1[32][7] ={
   0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,   //        Space
   0xFB,0xFB,0xFB,0xFB,0xFB,0xFF,0xFB,   //        !
   0xF5,0xF5,0xF5,0xFF,0xFF,0xFF,0xFF,   //        "
   0xF5,0xF5,0xE0,0xF5,0xE0,0xF5,0xF5,   //        #
   0xFB,0xF0,0xEB,0xF1,0xFA,0xE1,0xFB,   //        $
   0xE3,0xEA,0xE5,0xFB,0xF4,0xEA,0xF8,   //        %
   0xF7,0xEB,0xEB,0xF7,0xEA,0xED,0xF2,   //        &
   0xF9,0xF9,0xFD,0xFB,0xFF,0xFF,0xFF,   //        '
   0xFD,0xFB,0xF7,0xF7,0xF7,0xFB,0xFD,   //        (
   0xF7,0xFB,0xFD,0xFD,0xFD,0xFB,0xF7,   //        )
   0xFB,0xEA,0xF1,0xFB,0xF1,0xEA,0xFB,   //        *
   0xFF,0xFB,0xFB,0xE0,0xFB,0xFB,0xFF,   //        +
   0xFF,0xFF,0xFF,0xF3,0xF3,0xFB,0xF7,   //        ,
   0xFF,0xFF,0xFF,0xF1,0xFF,0xFF,0xFF,   //        -
   0xFF,0xFF,0xFF,0xFF,0xFF,0xF3,0xF3,   //        .
   0xFF,0xFE,0xFD,0xFB,0xF7,0xEF,0xFF,   //        /
   0xF1,0xEE,0xEC,0xEA,0xE6,0xEE,0xF1,   //        0
   0xFB,0xF3,0xFB,0xFB,0xFB,0xFB,0xF1,   //        1
   0xF1,0xEE,0xFE,0xF1,0xEF,0xEF,0xE0,   //        2
   0xF1,0xEE,0xFE,0xF9,0xFE,0xEE,0xF1,   //        3
   0xFD,0xF9,0xF5,0xED,0xE0,0xFD,0xFD,   //        4
   0xE0,0xEF,0xE1,0xFE,0xFE,0xFE,0xE1,   //        5
   0xF9,0xF7,0xEF,0xE1,0xEE,0xEE,0xF1,   //        6
   0xE0,0xFE,0xFD,0xFB,0xF7,0xF7,0xF7,   //        7
   0xF1,0xEE,0xEE,0xF1,0xEE,0xEE,0xF1,   //        8
   0xF1,0xEE,0xEE,0xF0,0xFE,0xFD,0xF3,   //        9
   0xFF,0xF3,0xF3,0xFF,0xF3,0xF3,0xFF,   //        :
   0xF3,0xFB,0xF3,0xF3,0xFF,0xF3,0xF3,   //        ;      
   0xFD,0xFB,0xF7,0xEF,0xF7,0xFB,0xFD,   //        <
   0xFF,0xFF,0xF1,0xFF,0xF1,0xFF,0xFF,   //        =
   0xF7,0xFB,0xFD,0xFE,0xFD,0xFB,0xF7,   //        >
   0xF1,0xEE,0xFE,0xFD,0xFB,0xFF,0xFB};  //        ?

const char font_2[32][7] ={
   0xF1,0xEE,0xFE,0xF2,0xEA,0xEA,0xF1,   //        @
   0xFB,0xF5,0xEE,0xEE,0xE0,0xEE,0xEE,   //        A
   0xE1,0xF6,0xF6,0xF1,0xF6,0xF6,0xE1,   //        B
   0xF1,0xEE,0xEF,0xEF,0xEF,0xEE,0xF1,   //        C
   0xE1,0xF6,0xF6,0xF6,0xF6,0xF6,0xE1,   //        D
   0xE0,0xEF,0xEF,0xE3,0xEF,0xEF,0xE0,   //        E
   0xE0,0xEF,0xEF,0xE3,0xEF,0xEF,0xEF,   //        F
   0xF1,0xEE,0xEF,0xE8,0xEE,0xEE,0xF1,   //        G
   0xEE,0xEE,0xEE,0xE0,0xEE,0xEE,0xEE,   //        H
   0xF1,0xFB,0xFB,0xFB,0xFB,0xFB,0xF1,   //        I
   0xF8,0xFD,0xFD,0xFD,0xFD,0xFD,0xF3,   //        J
   0xEE,0xED,0xEB,0xE7,0xEB,0xED,0xEE,   //        K
   0xEF,0xEF,0xEF,0xEF,0xEF,0xEF,0xE0,   //        L
   0xEE,0xE4,0xEA,0xEA,0xEE,0xEE,0xEE,   //        M
   0xEE,0xE6,0xEA,0xEC,0xEE,0xEE,0xEE,   //        N
   0xF1,0xEE,0xEE,0xEE,0xEE,0xEE,0xF1,   //        O
   0xE1,0xEE,0xEE,0xE1,0xEF,0xEF,0xEF,   //        P
   0xF1,0xEE,0xEE,0xEE,0xEA,0xED,0xF2,   //        Q
   0xE1,0xEE,0xEE,0xE1,0xEB,0xED,0xEE,   //        R
   0xF1,0xEE,0xEF,0xF1,0xFE,0xEE,0xF1,   //        S
   0xE0,0xFB,0xFB,0xFB,0xFB,0xFB,0xFB,   //        T
   0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,0xF1,   //        U
   0xEE,0xEE,0xEE,0xF5,0xF5,0xFB,0xFB,   //        V
   0xEE,0xEE,0xEE,0xEA,0xEA,0xE4,0xEE,   //        W
   0xEE,0xEE,0xF5,0xFB,0xF5,0xEE,0xEE,   //        X
   0xEE,0xEE,0xF5,0xFB,0xFB,0xFB,0xFB,   //        Y
   0xE0,0xFE,0xFD,0xFB,0xF7,0xEF,0xE0,   //        Z
   0xF1,0xF7,0xF7,0xF7,0xF7,0xF7,0xF1,   //        [
   0xFF,0xEF,0xF7,0xFB,0xFD,0xFE,0xFF,   //        \
   0xF1,0xFD,0xFD,0xFD,0xFD,0xFD,0xF1,   //        [
   0xFB,0xF5,0xEE,0xFF,0xFF,0xFF,0xFF,   //        ^
   0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xE0};  //        _

const char font_3[32][7] ={
   0xF3,0xF3,0xF7,0xFB,0xFF,0xFF,0xFF,   //        `
   0xFF,0xFF,0xF1,0xFE,0xF0,0xEE,0xF1,   //        a
   0xEF,0xEF,0xE9,0xE6,0xEE,0xE6,0xE9,   //        b
   0xFF,0xFF,0xF8,0xF7,0xF7,0xF7,0xF8,   //        c
   0xFE,0xFE,0xF2,0xEC,0xEE,0xEC,0xF2,   //        d
   0xFF,0xFF,0xF1,0xEE,0xE0,0xEF,0xF1,   //        e
   0xF9,0xF6,0xF7,0xE1,0xF7,0xF7,0xF7,   //        f
   0xFF,0xFF,0xF0,0xEE,0xF0,0xFE,0xF1,   //        g
   0xEF,0xEF,0xE9,0xE6,0xEE,0xEE,0xEE,   //        h
   0xFB,0xFF,0xF3,0xFB,0xFB,0xFB,0xF1,   //        i
   0xFD,0xFF,0xF9,0xFD,0xFD,0xFD,0xF3,   //        j
   0xF7,0xF7,0xF6,0xF5,0xF3,0xF5,0xF6,   //        k
   0xF3,0xFB,0xFB,0xFB,0xFB,0xFB,0xF1,   //        l
   0xFF,0xFF,0xE5,0xEA,0xEA,0xEA,0xEA,   //        m
   0xFF,0xFF,0xE9,0xE6,0xEE,0xEE,0xEE,   //        n
   0xFF,0xFF,0xF1,0xEE,0xEE,0xEE,0xF1,   //        o
   0xFF,0xFF,0xE1,0xEE,0xE1,0xEF,0xEF,   //        p
   0xFF,0xFF,0xF0,0xEE,0xF0,0xFE,0xFE,   //        q
   0xFF,0xFF,0xE9,0xE6,0xEF,0xEF,0xEF,   //        r
   0xFF,0xFF,0xF0,0xEF,0xF1,0xFE,0xE1,   //        s
   0xFB,0xFB,0xF0,0xFB,0xFB,0xFB,0xFC,   //        t
   0xFF,0xFF,0xEE,0xEE,0xEE,0xEC,0xF2,   //        u
   0xFF,0xFF,0xEE,0xEE,0xEE,0xF5,0xFB,   //        v
   0xFF,0xFF,0xEE,0xEE,0xEA,0xEA,0xF4,   //        w
   0xFF,0xFF,0xEE,0xF5,0xFB,0xF5,0xEE,   //        x
   0xFF,0xFF,0xEE,0xF5,0xFB,0xFB,0xF3,   //        y
   0xFF,0xFF,0xE0,0xFD,0xFB,0xF7,0xE0,   //        z
   0xF9,0xF7,0xF7,0xE7,0xF7,0xF7,0xF9,   //        {
   0xFB,0xFB,0xFB,0xFF,0xFB,0xFB,0xFB,   //        |
   0xF3,0xFD,0xFD,0xFC,0xFD,0xFD,0xF3,   //        }
   0xF5,0xEA,0xFF,0xFF,0xFF,0xFF,0xFF};  //        ~
void send(char val)
{
if(val&0x01)output_high(PIN_B0);
else output_low(PIN_B0);
if(val&0x02)output_high(PIN_B1);
else output_low(PIN_B1);
if(val&0x04)output_high(PIN_B2);
else output_low(PIN_B2);
}
void main()
{
   char i=0,j=0,k=0,d=0,n=0,m=0,s=0;
   int data;
   output_A(0x00);
   output_B(0x00);
   while(true)
   {
       for(j=0;j<8;j++)
       {    
       for(i=d;i<d+8;i++)
         {
         if (ky_tu[i]<='?')data=~font_1[ky_tu[i]-' '][j];
         else if (ky_tu[i]<='_')data=~font_2[ky_tu[i]-'@'][j];
         else if (ky_tu[i]<='~')data=~font_3[ky_tu[i]-'`'][j];
         if(j==7)data=0;
         for(k=0;k<8;k++)
           {
           output_bit(PIN_A1,shift_left(&data,1,0));
           if(k>0)
               {
                output_high(PIN_A0);
                output_low(PIN_A0);
               }
            output_low(PIN_A1); 
           }
         }
       for(k=0;k<n;k++)
                {
                 output_high(PIN_A0);
                 output_low(PIN_A0);
                }
       output_high(PIN_A2);     
       delay_us(500);
       output_low(PIN_A2);
       s++;
       send(s);
       if(s==8)s=0;
       }
       m++;
       if(m==5){m=0;n++;}
       if(n==7){n=0;d++;}
       if(d==21)d=0;
    }
}


Hình ảnh khi chạy mô phỏng :

Link download toàn bộ code và file mô phỏng bằng proteus tại đây :
 http://www.mediafire.com/download/breqe96rm6duu4b/LED+chay+chu.rar
Mạch này chỉ có 1 hiệu ứng chạy chữ , nếu các bạn muốn có nhiều hiệu ứng thêm thì có thể chỉnh sửa code....và mạch này chỉ mang tính tham khảo nên mìn không đảm bảo nếu các bạn làm mạch thực tế  có thể chử chạy sẽ bị giật

                                                                                   Nguồn :  phanhoangthach.blogspot.com

0 comments:

Post a Comment

domain, domain name, premium domain name for sales

Popular Posts