اريد تشغيل ليدين ولكن ليس في نفس الوقت يعني واحد ON والثاني OFF والعكس صحيح بخاصية PWM. انا اقترحت التوصيل معكوس واذا كان هناك طريقة افضل ياليت توصل لان طريقتي لم تفلح وهل الكود صحيح
كود:
void InitMain() {
ANSEL = 0; // Configure AN pins as digital
ANSELH = 0;
C1ON_bit = 0; // Disable comparators
C2ON_bit = 0;
PORTA = 255;
TRISA = 255; // configure PORTA pins as input
PORTB = 0; // set PORTB to 0
TRISB = 0; // designate PORTB pins as output
PORTC = 0; // set PORTC to 0
TRISC = 0; // designate PORTC pins as output
PWM1_Init(1000); // Initialize PWM1 module at 1KHz
PWM2_Init(1000); // Initialize PWM2 module at 1KHz
}
void main() {
InitMain();
current_duty = 50; // initial value for current_duty
current_duty1 = 50; // initial value for current_duty1
PWM1_Start(); // start PWM1
//delay_ms(100);
PWM2_Start(); // start PWM2
//delay_ms(100);
PWM1_Set_Duty(current_duty); // Set current duty for PWM1
PWM2_Set_Duty(current_duty1); // Set current duty for PWM2
while (1) { // endless loop
// if (PORTC.F1==1){PORTC.F2=0;}
portc.f1= ~portc.f2;
portc.f2= ~portc.f1;
}
}