PART 1 || PWM CONTROL WITH POTENTIOMETER || SPEED CONTROL WITH POTENTIO...



DC MOTORS SPEED CONTROLLING WITH POTENTIOMETER



CIRCUIT DIAGRAM: 




COMPONENTS LIST : 
  1. ARDUINO UNO / NANO
  2. L298N MOTOR DRIVER
  3. DC MOTORS
  4. 100K POTENTIOMETER
  5. BATTERY
  6. JUMPER WIRES

WE NEED TO REMOVE THE JUMPER PINS TO ENABLE THE PWM (PULSE WIDTH MODULATION) TO CONTROL THE SPEED OF THE MOTORS BY USING POTENTIOMETER TO CALIBRATE SPEED.

WE HAVE A BASIC PROGRAM TO CONTROL SPEED OF THE MOTORS, IN THE NEXT PROJECTS CONNECTION/CIRCUIT IS THE SAME PROCESS, WE JUST NEED TO ATTACH/CONNECT THE OTHER COMPONENTS TO THE ARDUINO BOARD FOR DIFFERENT USAGE OF THE COMPONENT.

THE PROJECT MAIN THEME IS TO CONTROL THE ROBOT SPEED IN DIFFERENT SITUATIONS AND TERRAINS ,IN REAL LIFE WE ARE DRIVING CARS AND WE CHANGING THE GEARS BY USING A GEAR ROD FOR INCREASING OR DECREASING THE SPEED OF THE CAR OR VEHICLES. SO ROBOTS ALSO USING THE SAME PROCESS.

SOURCE CODE:

int EnableA = 3;
int EnableB = 5;
int LMT1 = 4;//LEFT MOTOR TERMINAL
int LMT2 = 6;
int RMT1 = 7;//RIGHT MOTOR TERMINAL
int RMT2 = 8;
int potValue = 0;
int motorValue = 0;
void setup() {
pinMode(LMT1, OUTPUT);
pinMode(LMT2, OUTPUT);
pinMode(RMT1, OUTPUT);
pinMode(RMT2, OUTPUT);
pinMode(EnableA, OUTPUT);
pinMode(EnableB, OUTPUT);
pinMode(A0, INPUT);//POTENTIOMETER
}
void loop(){
int potValue = analogRead(A0);
int motorValue = map(potValue, 0, 1023, 0, 255);
digitalWrite(LMT1, HIGH);
digitalWrite(LMT2, LOW);
digitalWrite(RMT1, HIGH);
digitalWrite(RMT2, LOW);
analogWrite(EnableA, motorValue);
analogWrite(EnableB, motorValue);
}


Comments

Post a Comment