Skip to main content

SOURCE CODE

 import serial

import RPi.GPIO as GPIO


M1=13

M2=6

M3=7

M4=12


GPIO.setmode(GPIO.BCM)

GPIO.setup(M1,GPIO.OUT)

GPIO.setup(M2,GPIO.OUT)

GPIO.setup(M3,GPIO.OUT)

GPIO.setup(M4,GPIO.OUT)


port = serial.Serial("/dev/ttyAMA0", baudrate=9600, timeout=1)


data1=" "

data=" "


def left(): #left

    print("forward")

    

    GPIO.output(M1, True)    

    GPIO.output(M2, False)

    GPIO.output(M3, True)

    GPIO.output(M4, False)

    

def right():

    print('backward')

    

    GPIO.output(M1, False)

    GPIO.output(M2, True)

    GPIO.output(M3, False)

    GPIO.output(M4, True)


def backward():

    print('right')

    

    GPIO.output(M1, False)

    GPIO.output(M2, True)

    GPIO.output(M3, True)

    GPIO.output(M4, False)


def forward():

    print('left')

    

    GPIO.output(M1, True)

    GPIO.output(M2, False)

    GPIO.output(M3, False)

    GPIO.output(M4, True)


def stop():

    print('stop')

    

    GPIO.output(M1, True)

    GPIO.output(M2, True)

    GPIO.output(M3, False)

    GPIO.output(M4, False)

    


stop()


while 1:

 data = str(port.read(1))

 data1+=data

 a=data1[3]

 #print (data1)

 if 'U' in data1:

     forward()

 if 'D'in data1:

     backward()

 if 'R' in data1:

     right()

 if 'L' in data1:

     left()

 if 'C' in data1:

     stop()

     

 print(data1[3]) 

 port.flush()

 data=" "

 data1=" "


Popular posts from this blog

RASPBERRY PI BASED SURVEILLANCE ROBOT BLOCK DIAGRAM

                                       BLOCK DIAGRAM

APPLICATIONS

  1)      Military and aerospace embedded software applications 2)      Communication Applications 3)      Industrial automation and process control software 4)      Mastering the complexity of applications. 5)      Reduction of product design time. 6)      Real time processing of ever increasing amounts of data. 7)      Intelligent, autonomous sensors.

VOLTAGE REGULATOR

FEATURES   • Output Current up to 1A  • Output Voltages of 5, 6, 8, 9, 10, 12, 15, 18, 24V  • Thermal Overload Protection  • Short Circuit Protection  • Output Transistor Safe Operating Area Protection    DESCRIPTION  The LM78XX/LM78XXA series of three-terminal positive regulators are available in the TO-220/D-PAK package and with several fixed output voltages, making them useful in a Wide range of applications. Each type employs internal current limiting, thermal shutdown and safe operating area protection, making it essentially indestructible. If adequate heat sinking is provided, they can deliver over 1A output Current. Although designed primarily as fixed voltage regulators, these devices can be used with external components to obtain adjustable voltages and current