This code was written for a micromouse contest held in a World Robotics Festival called Technoxian. The project was written in a hurry and so the code is very unorganized, extremely sorry for that.
Initially during the development, stepper motors were used along with an arduino uno as the microcontroller. The arduino had to be multithreaded in order to control the acceleration of the steppers simultaneously. This required the creation of two continuous PWD(Pulse Width Modulation) signals that can be controlled seperately. This wasn't directly possible using an arduino uno because the arduino runs on a single looping cycle which is sufficient for generating only a single PWD signal. Software multithreading techniques were definitely a solution here but, after implementing them promising results weren't obtained. Finally, I discovered that the arduino itself comes equipped with PWD pins which can be manipulated using some registers and concepts related to interruptions. Basically, manipulation in the bits stored in some registers controlled the interruptions which were responsible for generating the desired frequency mapped to acceleration for a particular PWD signal. Finally, I was able to use this concept to establish simultaneous control over my stepper.
Moving on, I implemented the popular flood fill navigation technique to map out the maze and eventually figure out the shortest traversal path. My micromuse was finally ready, I just needed to replace my test steppers with a smaller version of them so as to be in the size constraints. I had ordered the smaller steppers online which were supposed to arrive 8 days before the competition. Unfortunately, one of my smaller steppers turned out to be defected putting me in extreme trouble.
I had 7 days left but still, very unrealistically, I restarted the project. I decided to use the usual, small DC motors readily available in my local market. Usage of steppers eliminates the requirement for the implementation of a PID(Praportional Integral Derivative) control mechanism because they are already precise and accurate in their movement. PID, essentially, helps in maintaining a straight path for the robot and because steppers are precise two simultaneous steppers scarcely differ in movement. For a DC motor, however, a slight variation in current could produce significant differences leading to an imbalance between the two motors controlling the wheels, ultimately deviating the robot from its path. Subsequently, over the course of 7 days, I learnt the PID algorithm and tried to implement it. Unfortunately, I ran out of time and the results produced were not that promising. Nevertheless, we learn a lot and I guess that's what matters in the end.