There are four variations to the program I have made.
Program #1: The first one is for the robot to follow smooth turns , sharp turns, and breaks in the line.
Program #2: The second one can handle victim finding, smooth turns, sharp turns, and breaks in the line.
Program #3:The third one can handle all the ones program #2 can handle with the addition of obstacle avoidance
Program #4:The fourth one is only obstacle avoiding.
The other final code does everything together - victims, line following, and obstacle avoiding.
NOTE: All the programs output display data to an LCD , but it is not necessary to connect an LCD, the program will run perfectly without it.
I have attached the BASIC code , the Assembly Language Code , and the hex file code for each program.
The only thing you would need to change in any of the programs is the following code.
Forward1 con 200
Forward2 con 100
Backward2 con 200
Backward1 con 100
If you modified the servos perfectly then leave the above code alone. If the servos are not turning right , play around with the above numbers until you get the desired motor movement. The numbers should be more than 99 but less than 201. Do not give it more than that
Also, if you can set the threshold value for the sensors. Once a sensor has a value more than LineColor it is considered to be seeing black. So also play around with that value until its the best it can be.
LineColor con 47000 ' the threshold value for a line being detected is 150
Now to upload the code to the microcontroller you do the following.
1. Put the PIC16F616 into the U2 programmer socket. Plug in the programmer. The green LED should be on.
2. Go to the folder where meprog.exe is located and double click it or instead of this open up the .pbp file in MicroCode Studio and Press F10, this should open up meprog.exe as well as compile the program.
3. Meprog.exe should now be opened up. Make sure that the device selected is the PIC16F616
4. Now click File and then click Open.
5. Find the hex file of the program and open it. For example, in the photo below I was uploading Program #2.
6. Now press Ctrl and P at the same time. This will begin uploading the code. A small window should pop up and now just let it run .
7. Once it says Finished , you are done and you can put the microcontroller in the robot and take it out of the programmer.