Hi,
Can some one please help me (n00b) with L298N motor driver. Im trying to make timelapse rail but now im stuck with this damm board. Im not sure is problem in code or not...
https://i0.wp.com/img.dxcdn.com/product ... 0475_2.jpg
Im very happy if some one could make example python code for this board to just run 1 motor.
Here is my code... oh and sry my bad english
#program asks how many pictures you wanna take then starts running when last picture is taken motor moves back to start
import wiringpi
from time import sleep
#Gpios
moottori_oikealle= 2 #motor foward
moottori_vasemmalle= 3 #motor reverse
suljin= 5 #shutter
#variables
moottori_odota1= 2.5 #time for rail settle before taking picture
moottori_odota2= 0.5 #motor waits
moottori_kay= 0.25 #motor runs foward
moottori_pakitus_maara= 0 #how many times motor need to run moottori_kay to be at start
suljin_aika= 0.5 #exposure is on this time
io= wiringpi.GPIO(wiringpi.GPIO.WPI_MODE_PINS)
io.pinMode(moottori_oikealle,io.OUTPUT)
io.pinMode(moottori_vasemmalle,io.OUTPUT)
io.pinMode(suljin,io.OUTPUT)
#asks how many pictures you want
kuvia= raw_input(" how many pictures you want ")
kuvia= int(kuvia)
while (kuvia > 0):
io.digitalWrite(moottori_oikealle,io.HIGH)
sleep(moottori_kay) #motor moves this time
io.digitalWrite(moottori_oikealle,io.LOW)
sleep (moottori_odota1)#time for rail settle before taking picture
io.digitalWrite(suljin,io.HIGH) #exposure starts
sleep(suljin_aika) #exposure is on this time
io.digitalWrite(suljin,io.LOW) #exposure ends
print "kuvia on ottamatta: " #prints how many pictures need to taken
print kuvia-1
sleep(moottori_odota2)
kuvia= kuvia-1
moottori_pakitus_maara= moottori_pakitus_maara+1
else:
while (moottori_pakitus_maara > 0): #motor will reverse
print "motor is driving reverse" ,moottori_pakitus_maara
io.digitalWrite(moottori_vasemmalle,io.HIGH)
sleep(moottori_kay)
io.digitalWrite(moottori_vasemmalle,io.LOW)
moottori_pakitus_maara= moottori_pakitus_maara-1
else:
print "DONE"