BẠN THỬ CODE NÀY NHA,
#include <16F877A.h>
#FUSES HS
#use delay(clock=8000000)
INT16 J ;
void main()
{
setup_ccp1(CCP_PWM);
setup_ccp2(CCP_PWM);
setup_timer_2(T2_DIV_BY_16, 255,1) ;
OUTPUT_C(0) ;
WHILE(TRUE)
{
FOR(J = 0 ; J < 1024 ; J ++ )
{
set_pwm1_duty(J);
set_pwm2_duty(J);
DELAY_MS(8) ;
}
}
}
|