Please try not to use adblocker for this small site. Thanks

Friday, 30 March 2018

Control different speed of a small DC motor with push button

Hi, in this post I would like to share with the sketch (down below) of a pwm speed controller and the diagram of it. By uploading the skecth to your Arduino board you will be able to control speed of a small dc motor without a potentiometer and without pressing the reset button. Thanks to Jerico ViƱas who shared the original sketch.

The sketch
const int motor = 4;
const int btn1 = 5;
const int btn2 = 6;
const int btn3 = 7;

int button1 = 0;
int button2 = 0;
int button3 = 0;
int var1 = 0;
int var2 = 0;
int var3 = 0;

void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(btn1,INPUT);
pinMode(btn2,INPUT);
pinMode(btn3,INPUT);
pinMode(motor,OUTPUT);

}

void loop() {
//Unlimited Execution
// Eco-Programmer
AST();
}

void AST(){
//This is the customized void
button1 = digitalRead(btn1);
button2 = digitalRead(btn2);
button3 = digitalRead(btn3);

if(button1 == HIGH){
var1=1;
var2=0;
var3=0;
Serial.write(var1);
}

if(button2 == HIGH){
var1=0;
var2=1;
var3=0;
Serial.write(var2);
}

if(button3 == HIGH){
var1=0;
var2=0;
var3=1;
Serial.write(var3);
}

if(var1 == 1){
digitalWrite(motor, HIGH);
delay(15);
digitalWrite(motor, LOW);
delay(40);
}

if(var2 == 1){
digitalWrite(motor, HIGH);
delay(15);
digitalWrite(motor, LOW);
delay(20);
}

if(var3 == 1){
digitalWrite(motor, HIGH);
delay(50);
digitalWrite(motor, LOW);
delay(10);
} else{
digitalWrite (motor, LOW);
 }
}




push button dc motor control arduino. arduino dc motor with push button. arduino push button dc motor. arduino dc motor control with button. motor button. button motor. arduino digitalread speed. speed control button. motor push button. control speed of dc motor arduino. dc motor with button arduino. arduino joystick dc motor control. arduino joystick motor control. dc motor speed control with joystick. arduino joystick dc motor control code. arduino dc motor speed control. push button motor. small dc motor arduino. arduino dc motor control code. arduino joystick motor control code. arduino control motor speed. dc motor joystick arduino. arduino dc motor potentiometer. 

arduino digitalwrite speed. speed control of dc motor using arduino. dc motor speed control arduino. how to control speed of dc motor using arduino. arduino uno motor control. motor speed control using arduino. dc motor control using arduino. arduino motor speed. arduino dc motor control. dc motor control arduino. control dc motor with potentiometer arduino. arduino joystick button code. dc motor control using arduino uno. arduino joystick push button. dc motor speed control arduino code.

9 comments:

  1. Can I use this concept to power up a 150v DC motor?

    ReplyDelete
  2. If I have a larger DC motor, I can control a DC motor controller with this program instead of use a potentiometer?

    ReplyDelete
  3. This coding I use in joystick L298 controller in wheelchair

    ReplyDelete
  4. can u show connection of arduino uno?

    ReplyDelete
    Replies
    1. You can use the code above it's the same thing with different pins setting maybe plus I don't have Arduino UNO and I don't really want to waste much time in it, reason can be found in the all Arduino posts.

      Delete