|
Re: More automonous help:ending stuff
Ok...well it's difficult to tell you exactly what to do without knowing your robot, but I'll try. There isn't a timing component in your code, it looks like, it just follows the line as far as it can, turning motors to different values when certain sensors see the line. Without some form of timing you won't be able to tell it to stop when you want, or time when the arm raises up/stops.
The simplest form of timer you can have is a program cycle counter, which will operate *around* 40hz, or about 25ms per count (its actually more like 28.something). So, add in a variable "count" (int count = 0; in your initialization) somewhere, and at the end of the loop say "count++;". Then, check when the count is higher than a certain number (the time you want to stop, or raise the arm, or stop raising the arm), and set the pwm values to something different that you want. Make sure to set those values lower in the loop than the sensor code, or they will get overridden.
You'll probably just have to time it yourself, or count the number of times a certain sensor sees the line (as in did it just turn?), and then raise the arm.
There are better ways of controlling the robot based on time and other factors, but its probably more complicated than you really have time for right now. Hope I helped.
__________________
~Alex Baxter
Programming, Arms operation, Team 254
|