PIC Vietnam

PIC Vietnam (http://www.picvietnam.com/forum/index.php)
-   Điều khiển (http://www.picvietnam.com/forum/forumdisplay.php?f=21)
-   -   gấp.........vấn đề về nguồn cho 16f877a (http://www.picvietnam.com/forum/showthread.php?t=33781)

dungcdt190502 15-09-2014 10:44 PM

gấp.........vấn đề về nguồn cho 16f877a
 
mọi người cho mình hỏi code sau mình mô phỏng chạy chuẩn mà sao khi nạp vào mạch no ko chạy ạ. chương trình có vấn đề j ko ạ.
#include <16F887.h>
#include <DEFS_16F877A.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=20000000)
#bit servo = porta.0
void servoRotate0() //0 Degree
{
unsigned int i;
for(i=0;i<50;i++)
{
servo = 1;
delay_us(800);
servo = 0;
delay_us(19200);
}
}

void servoRotate90() //90 Degree
{
unsigned int i;
for(i=0;i<50;i++)
{
servo = 1;
delay_us(1500);
servo = 0;
delay_us(18500);
}
}

void servoRotate180() //180 Degree
{
unsigned int i;
for(i=0;i<50;i++)
{
servo = 1;
delay_us(2200);
servo = 0;
delay_us(17800);
}
}

void main()
{
set_tris_a(0x00); //set các chân cua port c la chan xuat
porta = 0x00;
do
{
servoRotate0(); //0 Degree
delay_ms(2000);
servoRotate90(); //90 Degree
delay_ms(2000);
servoRotate180(); //180 Degree
}while(1);
}


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

Tên diễn đàn: vBulletin Version 3.8.11
Được sáng lập bởi Đoàn Hiệp.
Copyright © PIC Vietnam