[Project 13] – Angle Indicator with Servo Motor and 5 Buttons an Arduino

In this project we will make Angle Indicator with Servo Motor and 5 Button an Arduino. I will use arduino uno in the circuit design program. I use usually arduino mega 2560.  You can use the other arduino cards. Good Luck.

Circuit:


[Project 13] - Angle Indicator with Servo Motor and 5 Button an Arduino 1

Materials:


Arduino UNO / Other Arduino Cards        x 1
Breadboard    x 1
Servo Motor     x 1 
Button   x 5
2.2 kohm  Resistor    x 5
jumper Cable

Program:

// letsarduino.com
// [Project 13] - Angle Indicator with Servo Motor and 5 Button an Arduino
#include<Servo.h> 

Servo myservo;  
int button_1 = 2;
int button_2 = 3;
int button_3 = 4;
int button_4 = 5;
int button_5 = 6;
int time = 50; 
int val=0;

  void setup()  {
  pinMode(button_1, INPUT);
  pinMode(button_2, INPUT);
  pinMode(button_3, INPUT);
  pinMode(button_4, INPUT);
  pinMode(button_5, INPUT);
  myservo.attach(8); 
 }  
 
  void loop()
 { 
   val = digitalRead(button_1);
    if (val == HIGH) 
    {
      myservo.write(0); 
      delay(time);
    }
    val = digitalRead(button_2);
    if (val == HIGH) 
    {
      myservo.write(45); 
      delay(time);
    }
    val = digitalRead(button_3);
    if (val == HIGH) 
    {
      myservo.write(90); 
      delay(time);
    }
    val = digitalRead(button_4);
    if (val == HIGH) 
    {
      myservo.write(135); 
      delay(time);
    }
    val = digitalRead(button_5);
    if (val == HIGH) 
    {
      myservo.write(180); 
      delay(time);
    }
   }

 

Project Related Images:


[Project 13] - Angle Indicator with Servo Motor and 5 Button an Arduino 767[Project 13] - Angle Indicator with Servo Motor and 5 Button an Arduino 54



 

You may also like...