Many times my students ask me that how to mix number of robotics programs together. Actually this question should be asked as follows –
How can I control my robot to run on black track as well as as table top edge avoiding robot?
How to write obstacle avoiding robot code with line following robot code?
How to write obstacle avoiding robot code with table top edge avoiding robot code?
The answer to these questions is simple. Think of a task, for example, you want to control your robot as line following robot as well as table top edge avoiding robot. Then you will have to think logically and work out the code as follows –
- To control your robot as line following robot, you require two IR sensors.
- Now to control your robot as obstacle avoiding robot, as well, you need third IR sensor.
- It means that this task requires 3 IR sensors in total.
- Ok. Now we shall name these three IR sensors, in our code, as say, LS – left sensor, MS – middle sensor and RS – right sensor.
- We shall fix LS and RS horizontally, that is they will sense the black track below them.
- We shall fix MS vertically between the LS & RS such that MS is projecting quite outward, as compared to LS & RS, to detect the obstacle in front of it.
- This is our hardware setup.
- Now we shall discuss about the code.
How to write the code?
This task is not very complicated. What you need is the systematic and logical thinking. First we shall write the truth table about our required task.
- We have three IR sensors and they work on binary style.
- So, in all, we can have 8 possible combinations of the 3 IR sensors, as follows.
Download this truth table to understand the conditions, and how to implement them in your robotic program.
You may like this!
The multipurpose robotic code project for your kit, on this link.