### We all Know the working Of a DC motor but the drawback of using DC in our project is.

It Displaces the Bot a little ahead of the target or we can say it rotates a few more angles when turned off due to charge stored.

Causes-:

1. More Displacement Leads the bot to not  Follow the Track(Any track that requires stops) or even bot hits the wall or other bot because of that extra displacement that's why one has to practice with his bot for better understanding of controls(but its not efficient).

### Solutions-:

1. Use Low RPM Motors(But It still Also Stops after few Angles) accuracy percentage would be 50%.

2. Control the Voltage flow or Control the Speed of the motor to make your accuracy(depletion of extra angles) more close to 100%. for this solution to workout we have to learn something.

## So Let's First Learn About Arduino  Digital Write  And  Analog Write -:

First what's the Difference Between Analog and Digital-:

The Digitals are not Accurate to Each Decimal Point it Works on Approximation that's why Arduino Digital Write Has Only 2 Commands HIGH(1 or any number) OR LOW(0).

digitalWrite(6,HIGH); //Any number Instead of 0 in the Position of HIGH is treated as 1
digitalWrite(6,LOW);

The Analog is Obvious the Opposite of Digital it is Accurate and the Main Part is we can Assign Values Instead of HIGH OR LOW.
So, this is how the Speed of a DC motor is Controlled.

# USES-:

1. If you have 100 rpm motor and you don't have any Business with torque you just want  to drive your bot slow so you can do it now.

Notes-:
1.  Torque Doesn't Changes the torque provided by 100 rpm will be same if we are using it at a lower speed similar to 60 rpm.
2.  You can Increase the speed also but it will burn your motor.

Let's have a Test.

## CODE-:

void setup()
{

pinMode(6,OUTPUT);

pinMode(4,OUTPUT);

}

void loop()
{

digitalWrite(6,HIGH); //Common Voltage Supply to any motor

digitalWrite(4,LOW);

delay(3000);

analogWrite(6,150); //Controlling Speed Level 1

digitalWrite(4,LOW);

delay(3000);

analogWrite(6,50); //Controlling Speed level 2
digitalWrite(4,LOW);

delay(3000);

analogWrite(6,0); //Controlling Speed level n (n is any integer when the Motor Stops)

digitalWrite(4,LOW);

delay(3000);

}