Hackster is hosting Hackster Holidays, Ep. 5: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Friday!Stream Hackster Holidays, Ep. 5 on Friday!
Akshay Joseph
Published © GPL3+

Control Servo motor with Arduino Uno and Pushbutton

Control a Servo Motor with Arduino and a pushbutton. Servo only rotate when the pushbutton is pressed.

BeginnerProtip90,297
Control Servo motor with Arduino Uno and Pushbutton

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Pushbutton switch 12mm
SparkFun Pushbutton switch 12mm
×1
Jumper wires (generic)
Jumper wires (generic)
×1
UTSOURCE Electronic Parts
UTSOURCE Electronic Parts
×1
Resistor 10k ohm
Resistor 10k ohm
×1
General purpose pcb
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)
Solder Wire, Lead Free
Solder Wire, Lead Free
Solder Flux, Soldering
Solder Flux, Soldering

Story

Read more

Schematics

Control servo Motor With Arduino and push-button

Code

Control Servo Motor with Arduino and push-button

Arduino
//sketch created by Akshay Joseph follow me on Instagra: five_volt_player

include<Servo.h>
Servo Myservo;
int pos=0;
void setup()
{
  pinMode(2,INPUT);
  Myservo.attach(3);
}

void loop()
{
  if(digitalRead(2)==LOW){
    Myservo.write(180);
  }
  else
    
 Myservo.write(0);

}

Credits

Akshay Joseph

Akshay Joseph

25 projects • 157 followers
B.Sc. Electronics Student at Govt. College Tanur

Comments