unsigned long duty1,duty2;
// Duty Cycle in terms of a percentage.
unsigned long plus;
// Value read from A1, in case plus mode is activated
float xxx;
// Float numbers to calculate duty for PWM 1 and PWM 2
float yyy;
unsigned long pwm1;
// Value read from A0 and A2 to give PWM duty cycle output in terms // of 0-5V
unsigned long pwm2;
void setup(){
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
TCCR1A = _BV(COM1A1) | _BV(COM1B1) ; // phase and frequency correct mode. NON-inverted mode
//TCCR1A = _BV(COM1A1) | _BV(COM1B1) | _BV(COM1A0) | _BV(COM1B0) ;
TCCR1B = _BV(WGM13) | _BV(CS11);
}
void loop(){
ICR1 = 50; // Default value to 1kHz for A3 = 5V
pwm1 = analogRead(A2); // read duty from A2 for PWM 2
pwm2 = analogRead(A0); // read duty from A0 for PWM 1
xxx = float(pwm2);
yyy = float(pwm1);
xxx = xxx * ICR1;
yyy = yyy * ICR1;
xxx = xxx / 1023;
yyy = yyy / 1023;
OCR1B = int(xxx/2);
OCR1A = int(yyy/2);
}
According to the code,If I want to do a 180 degree phase shift . How can I modify the code ?
want