Book Image

Python Robotics Projects

By : Prof. Diwakar Vaish
Book Image

Python Robotics Projects

By: Prof. Diwakar Vaish

Overview of this book

Robotics is a fast-growing industry. Multiple surveys state that investment in the field has increased tenfold in the last 6 years, and is set to become a $100-billion sector by 2020. Robots are prevalent throughout all industries, and they are all set to be a part of our domestic lives. This book starts with the installation and basic steps in configuring a robotic controller. You'll then move on to setting up your environment to use Python with the robotic controller. You'll dive deep into building simple robotic projects, such as a pet-feeding robot, and more complicated projects, such as machine learning enabled home automation system (Jarvis), vision processing based robots and a self-driven robotic vehicle using Python. By the end of this book, you'll know how to build smart robots using Python.
Table of Contents (24 chapters)
Title Page
Packt Upsell
Contributors
Preface
Index

Making the robot detect pets


The preceding code is good, and I'm sure it would be dispensing the food at set times. However, there can be a problem, as the robot would not be effective if the pet does not know whether the food had been fetched. Hence, we need to have an alarm that should inform the pets that the food is ready to be eaten. 

Even in the previous program, we have used a buzzer that will inform the pet when the food is being dispensed, but, that was only for a very short period of time. However, what we are talking about here is an alarm system that will keep on ringing till the time the pet does not come and eat the food. To do this, connect the system as follows and mount the ultrasonic sensor in such a way that it notes the distance of the pet while he is eating the food.

Now, to do that, you will need to upload the following code:

import time
import Adafruit_ADS1x15
import RPi.GPIO as GPIO

Motor1a =  21
Motor1b = 20
Buzzer = 14
FSR = 16

GPIO.setmode(GPIO.BCM)
GPIO.setup(Motor1a...