Hello Karla,
It appears that this program is using a Software PWM, and here is an example program that might work
I have not configured a L298N in your configuration, and this example program may help. Here is some more explanation:
Public Property ENA As Integer
Public Property ENB As Integer
Public Property ForwardPinA1 As Integer
Public Property ForwardPinA2 As Integer
Public Property pi As pigpio
Public Property ReversePinB1 As Integer
Public Property ReversePinB2 As Integer
These public properties will hold data that is used in each of the buttons.
In an open event, the properties are assigned values, and the initial software PWM is setup.
Sub Open() Handles Open
//This line with the correct name of the class
//on the window must be added in the Window1 Open Event
//**Only call this once in the program**
pi = New pigpio
Call pi.gpioInitialise()
pi.Handle = pi.pigpio_start(nil, nil)
ForwardPinA1 = 23
ForwardPinA2 = 24
ReversePinB1 = 14
ReversePinB2 = 15
ENA = 25
ENB = 18
//Software PWM
//Set the pin to send output
Call pi.set_mode(ForwardPinA1, pi.OUTPUT)
Call pi.set_mode(ForwardPinA2, pi.OUTPUT)
Call pi.set_mode(ReversePinB1, pi.OUTPUT)
Call pi.set_mode(ReversePinB2, pi.OUTPUT)
//Set PWM range (0-255)
Call pi.gpioSetPWMRange(ENA, 255)
Call pi.gpioSetPWMRange(ENB, 255)
//Set PWM frequency (800 Hz is common)
Call pi.gpioSetPWMFrequency(ENA, 800)
Call pi.gpioSetPWMFrequency(ENB, 800)
End Sub
To make the PWM move the motor, the following code is placed in a button Action event:
Sub Action() Handles Action
//Move Forward Button
//PWM value 0 = low, 125 = 50%, 255 = High)
Call pi.gpioPWM(ForwardPinA1, 0)
Call pi.gpioPWM(ForwardPinA2, 0)
Call pi.gpioPWM(ReversePinB1, 255)
Call pi.gpioPWM(ReversePinB2, 255)
End Sub
Another button, lets call it Move Backward, may have code like this in the Action Event:
Sub Action() Handles Action
//Move Backward Button
//PWM value 0 = low, 125 = 50%, 255 = High)
Call pi.gpioPWM(ForwardPinA1, 255)
Call pi.gpioPWM(ForwardPinA2, 255)
Call pi.gpioPWM(ReversePinB1, 0)
Call pi.gpioPWM(ReversePinB2, 0)
End Sub
The duty cycle has a default range of 0-255, which can allow you to program different torque for the motor.
This is example code that was taken from Example 6-3 in the Raspberry Pi book.
I hope this helps.