Devices & Components
Arduino Uno Rev3
Jumper wires (generic)
SG90 Micro-servo motor
Software & Tools
Arduino IDE
Project description
Code
Arduino with Servo motor
c_cpp
Arduino with Servo motor loop
1//...............JehanKandy........................ 2//........www.jehankandy.com....................... 3//........www.github.com/JehanKandy................ 4 5//.......................Motors.................... 6//.........Servo Motor Function and for loop....... 7 8//in here you should include Servo.h lib.. 9#include <Servo.h> 10 11//define Servo motors 12Servo motor1; 13 14 15void setup() { 16 //define pins for Servo Motors 17 motor1.attach(2); 18 19} 20 21void loop() { 22 //Now in here you can call the all functions 23 Servom(); 24 Servoloop(); 25 26 27 28 29} 30//create function for Servo motoe -> Servom 31void Servom(){ 32 motor1.write(90); 33 delay(1000); 34 motor1.write(90); 35 delay(1000); 36} 37//create another function for for loop with servo motor -> Servoloop 38void Servoloop(){ 39 for(int i = 0; i <= 180; i=i+20){ //forword 40 motor1.write(i); 41 delay(100); 42 } 43 for(int q = 180; q >= 0; q=q-20){ //backword 44 motor1.write(q); 45 delay(1000); 46 } 47} 48 49//.........coded by : JehanKandy.... 50//...........Thank You.............. 51
Downloadable files
Arduino with Servo motor
Arduino with Servo motor loop
Arduino with Servo motor

Arduino with Servo motor
Arduino with Servo motor loop
Arduino with Servo motor

Comments
Only logged in users can leave comments