#C++, PWM using DC/AC H-bridge circuit

3 messages · Page 1 of 1 (latest)

copper lavaBOT
#

When your question is answered use !solved or the button below to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.

gilded hearth
#
 
void waveform(float p, float D)
{
      long high = p * (D);
      long low = p - high;
  
      // +ive current
      
     digitalWrite(Q2, LOW);
    digitalWrite(Q3, LOW);
      
      digitalWrite(Q1, HIGH);
    digitalWrite(Q4, HIGH);
    delayMicroseconds(high); 
  
    // -ive current
      digitalWrite(Q2, HIGH);
    digitalWrite(Q3, HIGH);
      digitalWrite(Q1, LOW);
    digitalWrite(Q4, LOW);  
    delayMicroseconds(low);
}
#

this is TInkerCAD btw