【正文】
k at Cell 1 in Graph 1. Perhaps the speeds of the two wheels are not the same. For example, the right wheel is run faster then the left one. Then the right sensor moves to the black trade. The robot should turn right. Look at Cell 2. If the robot goes to the round track, turns to right for example. The right sensor can fell the black trade too. Then the robot should turn to right. In a sentence, when the left/right sensor feel the trade, the robot should goes to the left/right. As we know, the direction of the wheel is controlled by H Bridge. The speed is controlled by PWM. The two wheels go front in full speed, the robot will go front. Some mates said that when the left wheel goes and the right one stops, the robot will turn right surround the right wheel. It’s sure. And this method creates the wonderful turns in the ophidian trade, because the radius of the round way is the same to the radius of robot. But there is a more sudden turn in the other side. I’m afraid the robot can’t turn such the sudden way. When turn to right, the left wheel goes front in full speed and the right one goes back in a low speed (PWM is 70). Timer 0 and Timer 2 act as the PWM controllers. The Timer 1 makes the interrupt. We use Timer1’s pare interruption. In the function main, we initialize the basic I/O ports, the timers and the interrupt of Timer 1. Then go to a dead loop. In this loop, we check the three variables: LeftSensor, CenterSensor and RightSonsor. They remember the status of the three sensors. In the interrupt function, we light the diodes and check the feedbacks of the sensors. And then remember them to the three variables: LeftSensor, CenterSensor and RightSonsor. This mission of line tracer is a little simple. But I found that it can’t always turn rightly on the sudden turn. I cut the time of interrupt, and it’s OK. The second function is keep away from the roadblock on the trade. I use the front sensor (on the robot) only. The program is update from Mission 1. At the interruption function of Timer 1, we light the 2 front diodes and open the A/D converter on. Then store the result of A/D conversion to the variable FrontEye. The lager FrontEye is, the nearer the object to the robot. In the main function, when the program runs to the dead loop, check the value of FrontEye. If it’s lager enough, it means that the robot is too near to the roadblock. Then I let the robot turns left. When turn left, I don’t use the right sensor but use a time delay. Let the right wheel goes front in full speed and the left one goes back in full speed. The robot will turn to left surround the center axis of the robot. Let the status delays a 1000*1000 time delay. The robot will turn 90 degree. At this time, the three lower sensors can’t feel the black trade, when the variables LeftSensor, CenterSensor and RightSonsor aren’t zeros. If this status happens, it means that the robot is 1 2 3 Graph 1 avoiding the roadblock. It should go front and turns to right slowly. We need make the radius large enough to the robot go round the block (I don’t use the right sensor). So let the left wheel goes front in full speed and the right one goes front in a lower speed (PWM is 160). When one of the lower sensors feels the block, the robot will go naturedly like analyzing in the Mission 1. It should be up to snuff. Mission 3 is thinking up a new idea. I don’t finish the mission on a map printing black trade. I’m dreaming to make a robot, which can go though a maze. I called it Maze Attacker. It can go through the maze that has a start point and an end point on the border of the maze. There is a theorem giving us a method. Stand at the start point, and make sure certain one of your touching the wall, and then you will find the end point. It tells us if the robot can go through the basement, it is a MA. So I wish to do a robot that can touch the wall. I call it WT. The basic configuratio