Quantcast
Channel: MSP430 Technical Forums
Viewing all articles
Browse latest Browse all 2077

PWM duty cycle not changing

$
0
0
Hi, I am trying to chane the duty cycle of an output PWM based on the duty cycle of an input PWM while leaving a constant PWM in one of the output. So far I have this code, but when I read the two output pins the duty cycle of the PWM are the same. Even when I set the duty cycle to different constants, the oscilloscope reads the same PWM. Any idea what I might be doing wrong?
 
 
//Constants
const int ThrotPin = A3; 
const int MotorP1 = 9; 
const int MotorP2 = 10; 
 
//Change
int val = 0; 
 
void setup()
{
  
  Serial.begin(9600);
  pinMode(ThrotPin, INPUT);
  pinMode(MotorP1, OUTPUT);
  pinMode(MotorP2, OUTPUT);
}
 
void loop(){
  while (1){
    
    val = analogRead(ThrotPin); 
    analogWrite(MotorP1,val);
    analogWrite(MotorP2,127);
  }
    
 
  
}

Viewing all articles
Browse latest Browse all 2077

Trending Articles