Hi,
I have to connect 4 servomotors, 2,12v DC motors ,LCD display and 4 sensors to raspberry. Is it possible to program everything in a single python file. Can anyone suggest a good method to get this done?
Of course its possible ...vishnuvkv wrote: Is it possible to program everything in a single python file.
Code: Select all
import RPi.GPIO as GPIO
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
GPIO.setup(13,GPIO.OUT)
p1=GPIO.PWM(13,50)#base
GPIO.setup(26,GPIO.OUT)
p2=GPIO.PWM(26,50)#side
GPIO.setup(19,GPIO.OUT)
p3=GPIO.PWM(19,50)#top
GPIO.setup(2,GPIO.IN,pull_up_down=GPIO.PUD_UP)#start/stop
GPIO.setup(3,GPIO.IN,pull_up_down=GPIO.PUD_UP)#fault
GPIO.setup(5,GPIO.IN)
scrap_count =0
while True:
a=GPIO.input(2)
a1=GPIO.input(3)
a2=GPIO.input(5)
# print a,a1
if (a==0 and a1==1 and a2==1):
time.sleep(10)
p3.start(7)
time.sleep(1)
p2.start(10.5)
time.sleep(1)
p3.ChangeDutyCycle(10)
time.sleep(1)
p2.ChangeDutyCycle(12)
time.sleep(1)
p1.start(6)
time.sleep(1)
p2.ChangeDutyCycle(10.5)
time.sleep(1)
p3.ChangeDutyCycle(7)
time.sleep(1)
p2.ChangeDutyCycle(12)
time.sleep(1)
p1.ChangeDutyCycle(10)
time.sleep(1)
scrap_count=scrap_count+1
print "Scrap Count = ",scrap_count
k=open('/home/pi/Hari/text_output_files/arm.txt','w')
k.write("Scrap Count = "+ str(scrap_count))
else:
p1.stop()
p2.stop()
p3.stop()
elif a==1:
scrap_count=0
k=open('/home/pi/Hari/text_output_files/arm.txt','w')
k.truncate()
You can, and should, preview your own post before submitting it. It looks unchanged to me.vishnuvkv wrote:I have edited the post .Please check
B.Goode wrote:You can, and should, preview your own post before submitting it. It looks unchanged to me.vishnuvkv wrote:I have edited the post .Please check
Code: Select all
makers. I am using this for the 1st time that is why I am asking.vishnuvkv wrote:B.Goode wrote:You can, and should, preview your own post before submitting it. It looks unchanged to me.vishnuvkv wrote:I have edited the post .Please check
The code you have posted does not appear to make any use of an LCD display so this will be impossible to diagnose.vishnuvkv wrote:Hi,
I am using a motor driver and 20*4 lcd display. When the motor is started lcd is displaying wrong characters. What may be the reason? please help
Sir,B.Goode wrote:The code you have posted does not appear to make any use of an LCD display so this will be impossible to diagnose.vishnuvkv wrote:Hi,
I am using a motor driver and 20*4 lcd display. When the motor is started lcd is displaying wrong characters. What may be the reason? please help
Killall pythonvishnuvkv wrote:Hi,
I will be running two python files in background using "&" operator but I am not able to stop them .Please help.
Thankyou