Page 125 - TCS ICT Book 8
P. 125

The City School  2021-2022





             #stop functionality
                elif (data == ”S”):

                  GPIO.output(MotorL1,False)
                  GPIO.output(MotorL2,False)

                  GPIO.output(MotorR1,False)
                  GPIO.output(MotorR2,False)

                  GPIO.output(16,False)
             #turn right functionality

                elif (data == ”R”):
                  GPIO.output(MotorL1,True)                                                                         Programming Robots & Single-Board Computers

                  GPIO.output(MotorL2,False)
                  GPIO.output(MotorR1,False)

                  GPIO.output(MotorR2,False)
             #turn left functionality

                elif (data == ”L”):
                  GPIO.output(MotorL1,False)

                  GPIO.output(MotorL2,False)
                  GPIO.output(MotorR1,True)

                  GPIO.output(MotorR2,False)
             client_sock.close()

             server_sock.close()


             After successfully entering this code and saving your file with the name of SRC.py follow
             these steps to connect your smart car using the android mobile device.


             1.  Connect and pair the Bluetooth of the mobile device
                with raspberry pi.

             2.  Open terminal and type sudo python SRC.py &                         Checkpoint
             3.  You will notice the blue LED light will be on Pi Shield,       In Python, a function is a group of
                                                                                related statements that perform a
                this means that bluetooth module is ready to                    specific task.
                connect.                                                        SONAR is an acronym of Sound
                                                                                Navigation & Ranging. It is used for
                                                                                measuring distance.
             4.  Open the TechTree-Bumble pi application on the
                                                                                A servo motor is an electrical device
                mobile device which you have already paired with                that can push or rotate an object with
                                                                                great precision.
                Bluetooth to this Raspberry Pi.










                                                                                                                125
   120   121   122   123   124   125   126   127   128   129   130