User:Skwon9642/ENES100 (Fall 14)/Project 3

Week1 Narrative
Task: need to figure out how to make the sensor and motors talk to each other so that the motor movement can move dependent of sensor values


 * combined the code for motors and sensor


 * After reading online, the error is because I am trying to compare the result of a function to a number.

Week2 Narrative

 * Task: keep working on if statements


 * After talking to Prof. Plotnick, I learned that I can use an array to separate the sensor values and make it in a usable form in which I can manipulate the numerical values of the sensor readings


 * Prof. Plotnick "arrays are the egg carton and the elements inside them are the eggs"


 * Prof. Plotnick suggested 2 options, whether to use an array for the 6 sensor values or to declare them individually.


 * I will use the array method (learn more)


 * Arrays are used in FOR LOOPS in most cases

 File:Array code.png|Array Example Code


 * tried to incorporate this into my code
 * the elements inside the array are analog pin readings (sensor readings)

 File:Array code 2.png|Array code trial (error) File:Array code 2 error.png|Array Code Error

next steps:


 * declare the sensVal in the upper part of the code

week3 narrative

 * After reading up on information on the arrays, I realized that the code I have already has an array and all I needed to do was get the "sensorValues" and make an if statement with it.


 * here is the code that I have currently


 * if sensor 3 value is reading more than 600, slow down the left motor (which will steer the car to the right)
 * if sensor 4 value is reading more than 600, slow down the right motor (which will steer the car to the left)
 * all other conditions, both motors spin in the same speed


 * the default value of a white floor is anywhere from 15-22
 * the default value of a black electrical tape is anywhere from 650-780
 * since there is a great amount of difference in the value, its safe to put the distinguisher as 600.


 * there is also another issue with the motors not spinning in the same speed. I adjusted the default speed to be equal but everytime the motor stops and starts back up, the spinning rate is different every time.
 * This should not be a big problem because the code will adjust the speed of the motor during the line read, so a slight difference in motor speed should not affect the overall direction of the robot.


 * Video of sensor input working
 * notice the white tape on the tires, which is there to distinguish the speed of the tires


 * After adjusting the speed of the motors and the delay speed to .01 milliseconds, I was able to see the final product.
 * Video of the final working robot.
 * The robot still has minor adjustments to make in order to follow the line more accurately.
 * The robot can only follow the line if it is placed on the line to begin with. otherwise, it has a difficult time detecting the line in the beignning.
 * The robot can only detect the line if its started at an angle that is almost parrallel to the black line, but if its perpendicular to the line, it will not start following the robot


 * next task:
 * create a code that will allow the robot to start following the line no matter how its placed initially.

week4 narrative

 * I have completely deleted the delay from all parts of the loop. This made the line readings far more accurate because the readings are refreshed constantly without delay
 * In attempt to have the robot to start following the line no matter the placement, I activated all the sensors (6). The code is as follows


 * sensors 1 & 2 act the same as sensor 3
 * sensors 5 & 6 act the same as sensor 4


 * this did not fix the issue. The robot still cannot detect the black line if placed at a significant angle (30 degrees or more)

next steps: Try to incorporate a stop function in the beginning of the setup function so that the robot stops when it detects the black line, giving it time to adjust

Week5 Narrative

 * made revisions to code for sharp turns.
 * since during a right 90 degree turn, sensor 3,4 and 5 will read a high value, I added a code saying that if 3,4, and 5 reads, high, stop the robot (this is to make clear that the motors are responding to the code)
 * opposite for left 90 degree turns.

 File:90degree turns.png|code inserted


 * This has no visible effect on how the robot runs. Robot still passes through a 90 degree line, and does not stop!...