Notifications
Clear all

Bizarre L298N Functioning

17 Posts
5 Users
0 Likes
5,172 Views
robotBuilder
(@robotbuilder)
Member
Joined: 5 years ago
Posts: 2042
 

Apparently you can use either and it is suggested it may be safer to use the BOARD numbers if you are going to use more than one RPi in a project.

The same code but this time using the BOARD numbers.



import RPi.GPIO as gpio
import time

def init():
gpio.setmode(gpio.BOARD)
gpio.setup(11,gpio.OUT)
gpio.setup(15,gpio.OUT)
gpio.setup(16,gpio.OUT)
gpio.setup(18,gpio.OUT)

def forward(tf):
init()
gpio.output(11,False)
gpio.output(15,True)
gpio.output(16,False)
gpio.output(18,True)
time.sleep(tf)
gpio.cleanup()

def reverse(tf):
init()
gpio.output(11,True)
gpio.output(15,False)
gpio.output(16,True)
gpio.output(18,False)
time.sleep(tf)
gpio.cleanup()

print ("forward")
forward(3)
print ("reverse")
reverse(3)

   
ReplyQuote
robotBuilder
(@robotbuilder)
Member
Joined: 5 years ago
Posts: 2042
 

Keep in mind I am also new to interfacing the RPi so I am in learning mode with the RPi as I am with the Python language.  This is only my second go at it as I have been concentrating on the Arduino coding up to now.  I used Python 3 but I can't answer your question as to the difference here.  I asked the question because in Python 3 you need to place the text to print in brackets.

print "hello"  vs  print ("hello")

 

 


   
ReplyQuote
Page 2 / 2