sbit speed_I at RB0_bit;
sbit speed_D at RB1_bit;
sbit speed_C at RB2_bit;
unsigned short A, const_duty;
#define delay delay_ms(50)
void Pic_Init(){
trisb=255;
trisd=0;
portd=0;
trisc=0;
portc=0;
pwm1_init(10000);
}
void main() {
Pic_Init();
const_duty=127;
PWM1_Start();
current_duty=0;
pwm1_set_duty(A);
while(1){
if(speed_I==1){
delay;
A++;
pwm1_set_duty(A);
if(current_duty==240){
A=240;
pwm1_set_duty(A);
}
}
if(speed_D==1){
delay;
A--;
pwm1_set_duty(A);
if(current_duty==16){
A=16;
pwm1_set_duty(A);
}
}
if(speed_C==1){
delay;
pwm1_set_duty(const_duty);
}
delay_ms(5);
}