PIC Vietnam

Go Back   PIC Vietnam > Microchip PIC > PIC - Thiết kế và Ứng dụng

Tài trợ cho PIC Vietnam
Trang chủ Đăng Kí Hỏi/Ðáp Thành Viên Lịch Bài Trong Ngày Vi điều khiển

PIC - Thiết kế và Ứng dụng Ý tưởng cho các sản phẩm sử dụng PIC/dsPIC và các sản phẩm của Microchip

Trả lời
 
Ðiều Chỉnh Xếp Bài
Old 17-06-2005, 06:42 PM   #1
PIC-NGHEO
Đệ tử 2 túi
 
PIC-NGHEO's Avatar
 
Tham gia ngày: Jun 2005
Bài gửi: 28
:
Mạch đèn viền bảng

Chào các sư phụ PIC.
Hôm nay PIC-NGHEO có cái mạch điện hơi bị nghèo, liều mạng share lên cho các sư phụ đóng góp nhằm mục đích cho PIC-NGHEO giàu thêm một chút
CCS C
Code:
///////////////////////////////////////////////////
//-Mach Den Led vien bang quang cao (dzom?)       //
//-PIC-NGHEO Thuc hien                                     //
//-Thuc hien ngay 17-06-2005 (moi toanh !!!)         //
//-Phan cung:                                                   //
//  *PIC 16F84A thach anh 10M                            //
//  *PIN BO-B1-B2-B3 (ra muc cao=+5V) noi voi led //
//   qua dien tro 470 om ( la 4 led nha!)                 //
//  *The la xong mach den Led toi 6 kieu !!!           //
//-Khuyet diem: Hoi bi dai dong !!! hehehe             //
//-ROM an het 97 % (Ngai qua! )                         //
///////////////////////////////////////////////////////////

#include <16F84A.h>
#fuses NOWDT,HS, NOPUT, NOPROTECT
#use delay(clock=10000000)

#define LED_0 PIN_B0
#define LED_1 PIN_B1
#define LED_2 PIN_B2
#define LED_3 PIN_B3

   main() {
   
     while(TRUE) {
     
//1- Chay tu trai qua phai 3 lan 

      output_high(LED_0);
      delay_ms(50);
      output_low(LED_0);
      delay_ms(50);
      output_high(LED_1);
      delay_ms(50);
      output_low(LED_1);
      delay_ms(50);
      output_high(LED_2);
      delay_ms(50);
      output_low(LED_2);
      delay_ms(50);
      output_high(LED_3);
      delay_ms(50);
      output_low(LED_3);
      delay_ms(50);
      
      output_high(LED_0);
      delay_ms(50);
      output_low(LED_0);
      delay_ms(50);
      output_high(LED_1);
      delay_ms(50);
      output_low(LED_1);
      delay_ms(50);
      output_high(LED_2);
      delay_ms(50);
      output_low(LED_2);
      delay_ms(50);
      output_high(LED_3);
      delay_ms(50);
      output_low(LED_3);
      delay_ms(50);
      
      output_high(LED_0);
      delay_ms(50);
      output_low(LED_0);
      delay_ms(50);
      output_high(LED_1);
      delay_ms(50);
      output_low(LED_1);
      delay_ms(50);
      output_high(LED_2);
      delay_ms(50);
      output_low(LED_2);
      delay_ms(50);
      output_high(LED_3);
      delay_ms(50);
      output_low(LED_3);
      delay_ms(50);
   
//2- Chay diem den tu trai qua phai 3 lan 

      output_low(LED_0);
      delay_ms(50);
      output_high(LED_0);
      delay_ms(50);
      output_low(LED_1);
      delay_ms(50);
      output_high(LED_1);
      delay_ms(50);
      output_low(LED_2);
      delay_ms(50);
      output_high(LED_2);
      delay_ms(50);
      output_low(LED_3);
      delay_ms(50);
      output_high(LED_3);
      delay_ms(50);
      
      output_low(LED_0);
      delay_ms(50);
      output_high(LED_0);
      delay_ms(50);
      output_low(LED_1);
      delay_ms(50);
      output_high(LED_1);
      delay_ms(50);
      output_low(LED_2);
      delay_ms(50);
      output_high(LED_2);
      delay_ms(50);
      output_low(LED_3);
      delay_ms(50);
      output_high(LED_3);
      delay_ms(50);
      
      output_low(LED_0);
      delay_ms(50);
      output_high(LED_0);
      delay_ms(50);
      output_low(LED_1);
      delay_ms(50);
      output_high(LED_1);
      delay_ms(50);
      output_low(LED_2);
      delay_ms(50);
      output_high(LED_2);
      delay_ms(50);
      output_low(LED_3);
      delay_ms(50);
      output_high(LED_3);
      delay_ms(50);

//3-Chay tu phai qua trai 3 lan 

      output_high(LED_3);
      delay_ms(50);
      output_low(LED_3);
      delay_ms(50);
      output_high(LED_2);
      delay_ms(50);
      output_low(LED_2);
      delay_ms(50);
      output_high(LED_1);
      delay_ms(50);
      output_low(LED_1);
      delay_ms(50);
      output_high(LED_0);
      delay_ms(50);
      output_low(LED_0);
      delay_ms(50);
      
      output_high(LED_3);
      delay_ms(50);
      output_low(LED_3);
      delay_ms(50);
      output_high(LED_2);
      delay_ms(50);
      output_low(LED_2);
      delay_ms(50);
      output_high(LED_1);
      delay_ms(50);
      output_low(LED_1);
      delay_ms(50);
      output_high(LED_0);
      delay_ms(50);
      output_low(LED_0);
      delay_ms(50);
      
      output_high(LED_3);
      delay_ms(50);
      output_low(LED_3);
      delay_ms(50);
      output_high(LED_2);
      delay_ms(50);
      output_low(LED_2);
      delay_ms(50);
      output_high(LED_1);
      delay_ms(50);
      output_low(LED_1);
      delay_ms(50);
      output_high(LED_0);
      delay_ms(50);
      output_low(LED_0);
      delay_ms(50);
      
//4-Chay diem den tu phai qua trai 3 lan
      
      output_low(LED_3);
      delay_ms(50);
      output_high(LED_3);
      delay_ms(50);
      output_low(LED_2);
      delay_ms(50);
      output_high(LED_2);
      delay_ms(50);
      output_low(LED_1);
      delay_ms(50);
      output_high(LED_1);
      delay_ms(50);
      output_low(LED_0);
      delay_ms(50);
      output_high(LED_0);
      delay_ms(50);

      output_low(LED_3);
      delay_ms(50);
      output_high(LED_3);
      delay_ms(50);
      output_low(LED_2);
      delay_ms(50);
      output_high(LED_2);
      delay_ms(50);
      output_low(LED_1);
      delay_ms(50);
      output_high(LED_1);
      delay_ms(50);
      output_low(LED_0);
      delay_ms(50);
      output_high(LED_0);
      delay_ms(50);                                                                                              
      
      output_low(LED_3);
      delay_ms(50);
      output_high(LED_3);
      delay_ms(50);
      output_low(LED_2);
      delay_ms(50);
      output_high(LED_2);
      delay_ms(50);
      output_low(LED_1);
      delay_ms(50);
      output_high(LED_1);
      delay_ms(50);
      output_low(LED_0);
      delay_ms(50);
      output_high(LED_0);
      delay_ms(50);
      
//5-Dao dong flip flop 4 lan

      output_high(LED_0);
      output_high(LED_2);
      delay_ms(100);
      output_low(LED_0);
      output_low(LED_2);
      delay_ms(100);
      output_high(LED_3);
      output_high(LED_1);
      delay_ms(100);
      output_low(LED_3);
      output_low(LED_1);
      delay_ms(100);
      
      output_high(LED_0);
      output_high(LED_2);
      delay_ms(100);
      output_low(LED_0);
      output_low(LED_2);
      delay_ms(100);
      output_high(LED_3);
      output_high(LED_1);
      delay_ms(100);
      output_low(LED_3);
      output_low(LED_1);
      delay_ms(100);
      
      output_high(LED_0);
      output_high(LED_2);
      delay_ms(100);
      output_low(LED_0);
      output_low(LED_2);
      delay_ms(100);
      output_high(LED_3);
      output_high(LED_1);
      delay_ms(100);
      output_low(LED_3);
      output_low(LED_1);
      delay_ms(100);
      
      output_high(LED_0);
      output_high(LED_2);
      delay_ms(100);
      output_low(LED_0);
      output_low(LED_2);
      delay_ms(100);
      output_high(LED_3);
      output_high(LED_1);
      delay_ms(100);
      output_low(LED_3);
      output_low(LED_1);
      delay_ms(100);

//6-Chop tat 3 lan

      output_high(PIN_B0);
      output_high(PIN_B1);
      output_high(PIN_B2);
      output_high(PIN_B3);
      delay_ms(250);
      output_low(PIN_B0);
      output_low(PIN_B1);
      output_low(PIN_B2);
      output_low(PIN_B3);
      delay_ms(250);
      
      output_high(PIN_B0);
      output_high(PIN_B1);
      output_high(PIN_B2);
      output_high(PIN_B3);
      delay_ms(250);
      output_low(PIN_B0);
      output_low(PIN_B1);
      output_low(PIN_B2);
      output_low(PIN_B3);
      delay_ms(250);
      
      output_high(PIN_B0);
      output_high(PIN_B1);
      output_high(PIN_B2);
      output_high(PIN_B3);
      delay_ms(250);
      output_low(PIN_B0);
      output_low(PIN_B1);
      output_low(PIN_B2);
      output_low(PIN_B3);
      delay_ms(250);
      
   }
}
Hết chỗ cho file hex hic!
PIC-NGHEO vẫn chưa có mặt trong diễn đàn   Trả Lời Với Trích Dẫn
Old 17-06-2005, 06:44 PM   #2
PIC-NGHEO
Đệ tử 2 túi
 
PIC-NGHEO's Avatar
 
Tham gia ngày: Jun 2005
Bài gửi: 28
:
Hex files

...Và đây là HEX FILES
Code:
:1000000000308A00192800000F308400000803190E
:10001000182803308D008C018C0B0C288D0B0B28BD
:100020003C308C008C0B122800000000800B09284B
:10003000003484011F3083058316061083120614D2
:1000400032308F00042083160610831206103230DF
:100050008F000420831686108312861432308F009E
:100060000420831686108312861032308F000420FD
:10007000831606118312061532308F000420831672
:1000800006118312061132308F0004208316861168
:100090008312861532308F00042083168611831256
:1000A000861132308F000420831606108312061446
:1000B00032308F000420831606108312061032306F
:1000C0008F000420831686108312861432308F002E
:1000D0000420831686108312861032308F0004208D
:1000E000831606118312061532308F000420831602
:1000F00006118312061132308F00042083168611F8
:100100008312861532308F000420831686118312E5
:10011000861132308F0004208316061083120614D5
:1001200032308F00042083160610831206103230FE
:100130008F000420831686108312861432308F00BD
:100140000420831686108312861032308F0004201C
:10015000831606118312061532308F000420831691
:1001600006118312061132308F0004208316861187
:100170008312861532308F00042083168611831275
:10018000861132308F000420831606108312061069
:1001900032308F000420831606108312061432308A
:1001A0008F000420831686108312861032308F0051
:1001B0000420831686108312861432308F000420A8
:1001C000831606118312061132308F000420831625
:1001D00006118312061532308F0004208316861113
:1001E0008312861132308F00042083168611831209
:1001F000861532308F0004208316061083120610F5
:1002000032308F0004208316061083120614323019
:100210008F000420831686108312861032308F00E0
:100220000420831686108312861432308F00042037
:10023000831606118312061132308F0004208316B4
:1002400006118312061532308F00042083168611A2
:100250008312861132308F00042083168611831298
:10026000861532308F000420831606108312061084
:1002700032308F00042083160610831206143230A9
:100280008F000420831686108312861032308F0070
:100290000420831686108312861432308F000420C7
:1002A000831606118312061132308F000420831644
:1002B00006118312061532308F0004208316861132
:1002C0008312861132308F00042083168611831228
:1002D000861532308F00042083168611831286150E
:1002E00032308F000420831686118312861132303B
:1002F0008F000420831606118312061532308F00FA
:100300000420831606118312061132308F00042058
:10031000831686108312861432308F0004208316D1
:1003200086108312861032308F0004208316061048
:100330008312061432308F000420831606108312B5
:10034000061032308F000420831686118312861522
:1003500032308F00042083168611831286113230CA
:100360008F000420831606118312061532308F0089
:100370000420831606118312061132308F000420E8
:10038000831686108312861432308F000420831661
:1003900086108312861032308F00042083160610D8
:1003A0008312061432308F00042083160610831245
:1003B000061032308F0004208316861183128615B2
:1003C00032308F000420831686118312861132305A
:1003D0008F000420831606118312061532308F0019
:1003E0000420831606118312061132308F00042078
:1003F000831686108312861432308F0004208316F1
:1004000086108312861032308F0004208316061067
:100410008312061432308F000420831606108312D4
:10042000061032308F000420831686118312861145
:1004300032308F00042083168611831286153230E5
:100440008F000420831606118312061132308F00AC
:100450000420831606118312061532308F00042003
:10046000831686108312861032308F000420831684
:1004700086108312861432308F00042083160610F3
:100480008312061032308F00042083160610831268
:10049000061432308F0004208316861183128611D1
:1004A00032308F0004208316861183128615323075
:1004B0008F000420831606118312061132308F003C
:1004C0000420831606118312061532308F00042093
:1004D000831686108312861032308F000420831614
:1004E00086108312861432308F0004208316061083
:1004F0008312061032308F000420831606108312F8
:10050000061432308F000420831686118312861160
:1005100032308F0004208316861183128615323004
:100520008F000420831606118312061132308F00CB
:100530000420831606118312061532308F00042022
:10054000831686108312861032308F0004208316A3
:1005500086108312861432308F0004208316061012
:100560008312061032308F00042083160610831287
:10057000061432308F0004208316061083120614EE
:10058000831606118312061564308F00042083162B
:1005900006108312061083160611831206116430AA
:1005A0008F00042083168611831286158316861009
:1005B0008312861464308F00042083168611831200
:1005C0008611831686108312861064308F000420F3
:1005D000831606108312061483160611831206155D
:1005E00064308F00042083160610831206108316D1
:1005F00006118312061164308F00042083168611C1
:1006000083128615831686108312861464308F0039
:100610000420831686118312861183168610831296
:10062000861064308F00042083160610831206148F
:10063000831606118312061564308F00042083167A
:1006400006108312061083160611831206116430F9
:100650008F00042083168611831286158316861058
:100660008312861464308F0004208316861183124F
:100670008611831686108312861064308F00042042
:1006800083160610831206148316061183120615AC
:1006900064308F0004208316061083120610831620
:1006A00006118312061164308F0004208316861110
:1006B00083128615831686108312861464308F0089
:1006C00004208316861183128611831686108312E6
:1006D000861064308F0004208316061083120614DF
:1006E000831686108312861483160611831206154C
:1006F0008316861183128615FA308F000420831624
:100700000610831206108316861083128610831635
:100710000611831206118316861183128611FA3090
:100720008F00042083160610831206148316861089
:1007300083128614831606118312061583168611FA
:1007400083128615FA308F00042083160610831258
:1007500006108316861083128610831606118312E4
:1007600006118316861183128611FA308F00042039
:1007700083160610831206148316861083128614BD
:1007800083160611831206158316861183128615A9
:10079000FA308F0004208316061083120610831689
:1007A0008610831286108316061183120611831693
:1007B000861183128611FA308F0004201C286300F2
:02400E00FA3F77
:00000001FF
;PIC16F84A
Có thế thôi mong các sư phụ góp ý + anh em tuy nghi xử trí
PIC-NGHEO vẫn chưa có mặt trong diễn đàn   Trả Lời Với Trích Dẫn
Old 17-06-2005, 07:39 PM   #3
falleaf
PIC Bang chủ
 
falleaf's Avatar
 
Tham gia ngày: May 2005
Bài gửi: 2,631
:
Send a message via Yahoo to falleaf
Bạn nên cung cấp thêm mạch nguyên lý để các bạn sinh viên mới học dễ làm. Hơn nữa cũng không mất công ngồi dò lại, vì dù sao bạn cũng đã có mạch nguyên lý rồi.

Rất cám ơn sự nhiệt tình chia sẻ của bạn
falleaf vẫn chưa có mặt trong diễn đàn   Trả Lời Với Trích Dẫn
Old 18-06-2005, 10:27 AM   #4
hphong23
Nhập môn đệ tử
 
hphong23's Avatar
 
Tham gia ngày: May 2005
Bài gửi: 9
:
Hic, bạn PIC-NGHEO có thể viết lại chương trình cho ngắn hơn được không. Theo mình thấy thì một số đoạn có thể dùng các vòng lặp để viết thì sẽ ngắn hơn thì phải. Chúc thành công!
hphong23 vẫn chưa có mặt trong diễn đàn   Trả Lời Với Trích Dẫn
Old 18-06-2005, 12:13 PM   #5
PIC-NGHEO
Đệ tử 2 túi
 
PIC-NGHEO's Avatar
 
Tham gia ngày: Jun 2005
Bài gửi: 28
:
Arrow ...Tiếp sơ đồ mạch điện

Linh kiện:
1- IC PIC16F84A
2- LED x 4 cái
3- R 470 Om x 4 cái
4- Thạch anh 10 M (ceramic - 3 chân)
5- Nguồn 5V.

Kết nối mạch: IC PIC16F84A

1- Chân 4 + chân 14 nối với +5V
2- Chân 5 nối với GND
3- Chân 15 + chân 16 nối với hai chân ngoài của thạch anh ( chân giữa của thạch anh nối với GND)
4- Lần lượt các chân 6; 7; 8; 9 tương ứng với RB0; RB1; RB2; RB3 -> nối tiếp qua R 470 Om tới cực dương của LED -> cực âm của LED nối với GND.

Cấp điện +5V cho mạch và... chấm hết.

-----------------------------------------------*
Mạch điện mang tính cách sườn căn bản (...rườm rà...!) chỉ có vài dòng lập đi lập lại, với mục đích chỉ rõ sự tuần hoàn lập luận trên cơ sở logic.
Tuy nhiên mạch có thể tối ưu nhằm tiết kiệm tài nguyên cho ROM. Các bạn có thể cắt bớt hoặc điều chỉnh lại tùy nghi với bài tập trên mạch căn bản này.
Hic ! PIC-NGHEO mới download PICC từ forum này và học gấp nên code nó ra thế ! chứ pro rồi thì ....! Tuy nhiên cũng ráng dở sách từ trang đầu và cố gắng tham gia với diễn đàn PIC yêu quí này để còn có cơ hội vui cùng sở thích.
Cảm ơn falleaf và hphong23 đã coi bài + góp ý .
Chúc cả nhà PIC vui

thay đổi nội dung bởi: PIC-NGHEO, 06-07-2005 lúc 10:27 AM.
PIC-NGHEO vẫn chưa có mặt trong diễn đàn   Trả Lời Với Trích Dẫn
Old 18-06-2005, 10:18 PM   #6
CHIBANG
Nhập môn đệ tử
 
Tham gia ngày: Jun 2005
Bài gửi: 2
:
Bác này nhập môn như vậy là cũng được rùi, chắc mới vào nghề.

Bác nên dùng 1 ngắt timer, trong ngắt này làm 1 biến và tăng dần và làm các lệnh:
//Ngắt
i++;
if(i==1)
{
Làm việc gì đo;
}
if(i==3)
{
Làm việc gì đó;
}
...
if(i==MAX)
{
i=0;
//kết thúc 1 chu trình
}
//Kết thúc ngắt.
Tuy nhiên có thể dùng lệnh Case... thay if.
Như vậy chỉ cần dùng 1 biến+ 1 ngắt là làm tuốt mọi thứ. Dùng delay như bác thì chết chết.
CHIBANG vẫn chưa có mặt trong diễn đàn   Trả Lời Với Trích Dẫn
Old 23-06-2005, 12:04 PM   #7
PIC-NGHEO
Đệ tử 2 túi
 
PIC-NGHEO's Avatar
 
Tham gia ngày: Jun 2005
Bài gửi: 28
:
LED viền bảng Update !

///////////////////////////////////////////////////////////
//-Mach Den Led vien bang quang cao (update)
//-PIC-NGHEO Thuc hien
//-Thuc hien ngay 23-06-2005 (moi toanh !!!)
//-Phan cung:
// *PIC 16F84A thach anh 10M
// *PIN BO-B1-B2-B3 (ra muc cao=+5V) noi voi led
// qua dien tro 470 om ( la 4 led nha!)
// *Chuc nang moi voi 11 (12) chu ky hieu ung
//
///////////////////////////////////////////////////////////

#include <16F84A.h>
#fuses NOWDT,HS, NOPUT, NOPROTECT
#use delay(clock=10000000)

#define LED_0 PIN_B0
#define LED_1 PIN_B1
#define LED_2 PIN_B2
#define LED_3 PIN_B3

void main()
{
int8 i;

while(TRUE) {

//1- Chay diem sang tu trai qua phai 20 lan

for(i = 0; i < 20; i++) {
output_high(LED_0);
delay_ms(70);
output_low(LED_0);
output_high(LED_1);
delay_ms(70);
output_low(LED_1);
output_high(LED_2);
delay_ms(70);
output_low(LED_2);
output_high(LED_3);
delay_ms(70);
output_low(LED_3);
}

//2- Chay diem den tu trai qua phai 20 lan

for(i = 0; i < 20; i++) {
output_low(LED_0);
delay_ms(70);
output_high(LED_0);
output_low(LED_1);
delay_ms(70);
output_high(LED_1);
output_low(LED_2);
delay_ms(70);
output_high(LED_2);
output_low(LED_3);
delay_ms(70);
output_high(LED_3);
}

//4-Chay diem sang tu phai qua trai 20 lan

for(i = 0; i < 20; i++) {
output_high(LED_3);
delay_ms(70);
output_low(LED_3);
output_high(LED_2);
delay_ms(70);
output_low(LED_2);
output_high(LED_1);
delay_ms(70);
output_low(LED_1);
output_high(LED_0);
delay_ms(70);
output_low(LED_0);
}

//5-Chay diem den tu phai qua trai 20 lan

for(i = 0; i < 20; i++) {
output_low(LED_3);
delay_ms(70);
output_high(LED_3);
output_low(LED_2);
delay_ms(70);
output_high(LED_2);
output_low(LED_1);
delay_ms(70);
output_high(LED_1);
output_low(LED_0);
delay_ms(70);
output_high(LED_0);
}

//6-Chop tat 10 lan

for(i = 0; i < 10; i++) {

output_high(LED_0);
output_high(LED_1);
output_high(LED_2);
output_high(LED_3);
delay_ms(150);
output_low(LED_0);
output_low(LED_1);
output_low(LED_2);
output_low(LED_3);
delay_ms(150);
}

//7-Dao dong flipflop 10 lan

for(i = 0; i < 10; i++) {

output_high(LED_0);
output_high(LED_1);

output_low(LED_2);
output_low(LED_3);
delay_ms(150);

output_low(LED_0);
output_low(LED_1);

output_high(LED_2);
output_high(LED_3);
delay_ms(150);
}

//8-Chop duoi diem sang 10 lan

for(i = 0; i < 10; i++) {
output_high(LED_0);
delay_ms(35);
output_low(LED_0);
delay_ms(35);
output_high(LED_0);
delay_ms(35);
output_low(LED_0);
delay_ms(35);

output_high(LED_1);
delay_ms(35);
output_low(LED_1);
delay_ms(35);
output_high(LED_1);
delay_ms(35);
output_low(LED_1);
delay_ms(35);

output_high(LED_2);
delay_ms(35);
output_low(LED_2);
delay_ms(35);
output_high(LED_2);
delay_ms(35);
output_low(LED_2);
delay_ms(35);

output_high(LED_3);
delay_ms(35);
output_low(LED_3);
delay_ms(35);
output_high(LED_3);
delay_ms(35);
output_low(LED_3);
delay_ms(35);
}

//9-Chop duoi diem den 10 lan

for(i = 0; i < 10; i++) {
output_low(LED_0);
delay_ms(35);
output_high(LED_0);
delay_ms(35);
output_low(LED_0);
delay_ms(35);
output_high(LED_0);
delay_ms(35);

output_low(LED_1);
delay_ms(35);
output_high(LED_1);
delay_ms(35);
output_low(LED_1);
delay_ms(35);
output_high(LED_1);
delay_ms(35);

output_low(LED_2);
delay_ms(35);
output_high(LED_2);
delay_ms(35);
output_low(LED_2);
delay_ms(35);
output_high(LED_2);
delay_ms(35);

output_low(LED_3);
delay_ms(35);
output_high(LED_3);
delay_ms(35);
output_low(LED_3);
delay_ms(35);
output_high(LED_3);
delay_ms(35);
}

//10-Chop duoi nguoc diem sang 10 lan

for(i = 0; i < 10; i++) {
output_high(LED_3);
delay_ms(35);
output_low(LED_3);
delay_ms(35);
output_high(LED_3);
delay_ms(35);
output_low(LED_3);
delay_ms(35);

output_high(LED_2);
delay_ms(35);
output_low(LED_2);
delay_ms(35);
output_high(LED_2);
delay_ms(35);
output_low(LED_2);
delay_ms(35);

output_high(LED_1);
delay_ms(35);
output_low(LED_1);
delay_ms(35);
output_high(LED_1);
delay_ms(35);
output_low(LED_1);
delay_ms(35);

output_high(LED_0);
delay_ms(35);
output_low(LED_0);
delay_ms(35);
output_high(LED_0);
delay_ms(35);
output_low(LED_0);
delay_ms(35);
}

//11-Chop duoi nguoc diem den 10 lan

for(i = 0; i < 10; i++) {
output_low(LED_3);
delay_ms(35);
output_high(LED_3);
delay_ms(35);
output_low(LED_3);
delay_ms(35);
output_high(LED_3);
delay_ms(35);

output_low(LED_2);
delay_ms(35);
output_high(LED_2);
delay_ms(35);
output_low(LED_2);
delay_ms(35);
output_high(LED_2);
delay_ms(35);

output_low(LED_1);
delay_ms(35);
output_high(LED_1);
delay_ms(35);
output_low(LED_1);
delay_ms(35);
output_high(LED_1);
delay_ms(35);

output_low(LED_0);
delay_ms(35);
output_high(LED_0);
delay_ms(35);
output_low(LED_0);
delay_ms(35);
output_high(LED_0);
delay_ms(35);
}

//12-Chop tat 10 lan

for(i = 0; i < 10; i++) {

output_high(LED_0);
output_high(LED_1);
output_high(LED_2);
output_high(LED_3);
delay_ms(150);
output_low(LED_0);
output_low(LED_1);
output_low(LED_2);
output_low(LED_3);
delay_ms(150);

}
}
}
__________________
..::Được che chở có đáng gì? Được tự do mới quý::..

thay đổi nội dung bởi: PIC-NGHEO, 23-06-2005 lúc 12:07 PM.
PIC-NGHEO vẫn chưa có mặt trong diễn đàn   Trả Lời Với Trích Dẫn
Old 23-06-2005, 12:05 PM   #8
PIC-NGHEO
Đệ tử 2 túi
 
PIC-NGHEO's Avatar
 
Tham gia ngày: Jun 2005
Bài gửi: 28
:
HEX Files

Hex file

:1000000000308A001928000010308400000803190D
:10001000182803308D008C018C0B0C288D0B0B28BD
:100020003C308C008C0B122800000000800B09284B
:10003000003484011F3083058F010F08133C031C1B
:100040004F288316061083120614463090000420B1
:1000500083160610831206108316861083128614E8
:100060004630900004208316861083128610831673
:1000700006118312061546309000042083160611DF
:10008000831206118316861183128615463090005E
:10009000042083168611831286118F0A1D288F0172
:1000A0000F08133C031C82288316061083120610C7
:1000B000463090000420831606108312061483161F
:1000C0008610831286104630900004208316861016
:1000D000831286148316061183120611463090008F
:1000E00004208316061183120615831686118312C7
:1000F00086114630900004208316861183128615DF
:100100008F0A50288F010F08133C031CB528831653
:1001100086118312861546309000042083168611BE
:10012000831286118316061183120615463090003D
:10013000042083160611831206118316861083127B
:100140008614463090000420831686108312861091
:10015000831606108312061446309000042083167E
:100160000610831206108F0A83288F010F08133C94
:10017000031CE828831686118312861146309000EE
:1001800004208316861183128615831606118312A6
:1001900006114630900004208316061183120615BE
:1001A0008316861083128610463090000420831632
:1001B00086108312861483160610831206104630AA
:1001C0009000042083160610831206148F0AB628A6
:1001D0008F010F08093C031C152983160610831292
:1001E0000614831686108312861483160611831252
:1001F000061583168611831286159630900004200A
:10020000831606108312061083168610831286103A
:100210008316061183120611831686118312861126
:100220009630900004208F0AE9288F010F08093CBE
:10023000031C4229831606108312061483168610A7
:1002400083128614831606118312061183168611F3
:1002500083128611963090000420831606108312B4
:1002600006108316861083128610831606118312D9
:100270000615831686118312861596309000042089
:100280008F0A16298F010F08093C031CB929831610
:1002900006108312061423309000042083160610E3
:1002A0008312061023309000042083160610831258
:1002B00006142330900004208316061083120610C3
:1002C0002330900004208316861083128614233076
:1002D000900004208316861083128610233090002D
:1002E0000420831686108312861423309000042085
:1002F0008316861083128610233090000420831604
:10030000061183120615233090000420831606116F
:1003100083120611233090000420831606118312E5
:10032000061523309000042083160611831206114F
:100330002330900004208316861183128615233003
:1003400090000420831686118312861123309000BA
:100350000420831686118312861523309000042012
:1003600083168611831286112330900004208F0A91
:1003700043298F010F08093C031C302A83160610FD
:100380008312061023309000042083160610831277
:1003900006142330900004208316061083120610E2
:1003A0002330900004208316061083120614233095
:1003B000900004208316861083128610233090004C
:1003C00004208316861083128614233090000420A4
:1003D0008316861083128610233090000420831623
:1003E0008610831286142330900004208316061191
:1003F0008312061123309000042083160611831205
:10040000061523309000042083160611831206116E
:100410002330900004208316061183120615233022
:1004200090000420831686118312861123309000D9
:100430000420831686118312861523309000042031
:1004400083168611831286112330900004208316B0
:100450008611831286152330900004208F0ABA2952
:100460008F010F08093C031CA72A831686118312EB
:10047000861523309000042083168611831286117E
:1004800023309000042083168611831286152330B2
:100490009000042083168611831286112330900069
:1004A00004208316061183120615233090000420C1
:1004B0008316061183120611233090000420831640
:1004C00006118312061523309000042083160611AE
:1004D00083120611233090000420831686108312A5
:1004E0008614233090000420831686108312861011
:1004F0002330900004208316861083128614233044
:1005000090000420831686108312861023309000FA
:100510000420831606108312061423309000042052
:1005200083160610831206102330900004208316D1
:100530000610831206142330900004208316061040
:10054000831206102330900004208F0A312A8F0175
:100550000F08093C031C1E2B83168611831286117B
:1005600023309000042083168611831286152330D1
:100570009000042083168611831286112330900088
:1005800004208316861183128615233090000420E0
:10059000831606118312061123309000042083165F
:1005A00006118312061523309000042083160611CD
:1005B0008312061123309000042083160611831243
:1005C00006152330900004208316861083128610AF
:1005D0002330900004208316861083128614233063
:1005E000900004208316861083128610233090001A
:1005F0000420831686108312861423309000042072
:1006000083160610831206102330900004208316F0
:10061000061083120614233090000420831606105F
:1006200083120610233090000420831606108312D4
:1006300006142330900004208F0AA82A8F010F0887
:10064000093C031C4B2B83160610831206148316D9
:1006500086108312861483160611831206158316DC
:10066000861183128615963090000420831606109A
:1006700083120610831686108312861083160611C5
:10068000831206118316861183128611963090000C
:0A06900004208F0A1F2B1C286300B2
:02400E00FA3F77
:00000001FF
;PIC16F84A

----------------------------------------------
Copy and pate vào Notepad, sau đó Save as... chọn tiêu chuẩn All files với tên ledxx.HEX
__________________
..::Được che chở có đáng gì? Được tự do mới quý::..
PIC-NGHEO vẫn chưa có mặt trong diễn đàn   Trả Lời Với Trích Dẫn
Old 16-03-2006, 12:44 PM   #9
vivid
Nhập môn đệ tử
 
Tham gia ngày: Mar 2006
Bài gửi: 2
:
link đã bị hỏng rồi bác, check lại dùm em cái
cũng mới bắt đầu học pic, mặc dù nghe nói về pic đã từ lâu ( liệu có dốt quá không các bác nhỉ )
vivid vẫn chưa có mặt trong diễn đàn   Trả Lời Với Trích Dẫn
Old 17-03-2006, 09:06 AM   #10
hpecom
Đệ tử 2 túi
 
Tham gia ngày: Nov 2005
Bài gửi: 45
:
Theo tại hạ thì bác PICC-NGHEO nên xây dựng một hàm Khiển PIN, hàm sẽ có hai tham số: Pin_Num: 1, 2, 3 và Pin_val: true, false.
Ở chương trình chính bác viết vòng lặp for để gọi hàm này lồng vào các hàm delay và đương nhiên for này phải ở trong while.
Nếu bác muốn nhiều kiểm chớp thì nên xây dựng thêm các hàm chớp kiểu. Lúc đó các hàm chớp sẽ gọi hàm Khiển PIN, còn ở chương trình chính sẽ gọi các hàm chớp kiểu.
Tôi nghĩ làm vậy sẽ giảm code.
Xin hết.
hpecom.
hpecom vẫn chưa có mặt trong diễn đàn   Trả Lời Với Trích Dẫn
Old 21-04-2006, 05:07 PM   #11
hvktdk9
Đệ tử 1 túi
 
Tham gia ngày: Oct 2005
Bài gửi: 11
:
bạn nên đưa cả sơ đồ nguyên lý, chỉ nói cách đấu như vậy đối với người mới học thì không hiểu được
hvktdk9 vẫn chưa có mặt trong diễn đàn   Trả Lời Với Trích Dẫn
Old 21-04-2006, 05:39 PM   #12
minhpic
Đệ tử 9 túi
 
Tham gia ngày: Nov 2005
Bài gửi: 99
:
cho file hex dể dọa nhau à bạn?
minhpic vẫn chưa có mặt trong diễn đàn   Trả Lời Với Trích Dẫn
Trả lời


Quyền Sử Dụng Ở Diễn Ðàn
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is Mở
Smilies đang Mở
[IMG] đang Mở
HTML đang Tắt

Chuyển đến


Múi giờ GMT. Hiện tại là 05:08 AM.


Được sáng lập bởi Đoàn Hiệp
Powered by vBulletin®
Page copy protected against web site content infringement by Copyscape
Copyright © PIC Vietnam