DavidAtanasoski
Posts: 37
Joined: Mon Jul 09, 2018 2:37 pm

Need help about PWM on RPi with WiringPi library

Wed Jul 18, 2018 5:23 pm

Dear all members of this forum,
I need PWM control for DC motor. I'm using L293d motor driver. The code should be written in C++. I've made one in C++ for controlling DC motor, but now I got stuck to make it PWM. I need your help. I can't find anything on the internet.

Here is the code in C++ for the DC motors:

Code: Select all

#include <wiringPi.h>


int main (void)
{
  wiringPiSetup () ;

  int Motor1E = 2; //13
  int Motor1A = 0; //11
  int Motor1B = 1; //12

  int Motor2E = 21; //29
  int Motor2A = 22; //31
  int Motor2B = 23; //33


  pinMode (Motor1E, OUTPUT);
  pinMode (Motor1A, OUTPUT);
  pinMode (Motor1B, OUTPUT);

  pinMode (Motor2E, OUTPUT);
  pinMode (Motor2A, OUTPUT);
  pinMode (Motor2B, OUTPUT);

  for (;;)
  {
    digitalWrite (Motor1E, HIGH);
    digitalWrite (Motor1A, HIGH);
    digitalWrite (Motor1B, LOW);

    digitalWrite (Motor2E, HIGH);
    digitalWrite (Motor2A, HIGH);
    digitalWrite (Motor2B, LOW);

    delay (10000) ;


    digitalWrite (Motor2E, LOW);
    digitalWrite (Motor1E, LOW);

    delay (10000);

  }
  return 0 ;
}
I hope someone will help me to make it.
Enthusiast.


DavidAtanasoski
Posts: 37
Joined: Mon Jul 09, 2018 2:37 pm

Re: Need help about PWM on RPi with WiringPi library

Wed Jul 18, 2018 8:51 pm

How can I implement this? I need example, please.
Enthusiast.


Return to “Troubleshooting”

Who is online

Users browsing this forum: gkaiseril, gkreidl, HiassofT and 56 guests