TASK 2: ARDUINO CODE - Q-Division-2019-2020-Even/Team-9 GitHub Wiki

Program for Arduino.

#include <Servo.h>

int i;

int n=15;

int ledPin = 13; //LED to indicate completion of winding

int servoPin = 9; //Pin for servo motor 1

int servoPin = 8; //Pin for servo motor 2

int motorPin1 = 11; //Pin for DC motor

int motorPin2 = 12; //Pin for DC motor

Servo servo; // Create a servo object

void setup()

{

  pinMode(ledPin, OUTPUT);
  
  pinMode(motorPin1,OUTPUT);

  pinMode(motorPin2,OUTPUT);

  Serial.begin(9600);

}

void loop()

{

  Servo.attach(servoPin1);                  //We need to attach the servo to the used pin number

  digitalWrite(motorPin1, HIGH);           //Starting the DC motor with maximum speed in clockwise direction by which winding starts

  digitalWrite(motorPin2, LOW);      

  for (i =0; i <= n; i++)

  {

        Servo.write(60);                          //Linear motion of thread holder

        Servo.write(120);                         //Servo motor 1 goes from 0 degree to 120 degrees and then back to 0 degree (to and fro motion) 

        delay(1500);                             //Wait for 1.5 seconds

        Servo.write(60); 

        delay(1500);                            //Wait for 1.5 seconds
  }

  Servo.detach();                          //Stop servo motor 1 which stops linear motion

  digitalWrite(motorPin1, LOW);            //Stop dc motor which stops winding

  digitalWrite(motorPin2, LOW);

  digitalWrite(ledPin, HIGH);             //Turn the LED on to indicate the completion of winding(HIGH is the voltage level)

  delay(2000);                             //Wait for 2 second

  digitalWrite(ledPin, LOW);              //Turn the LED off by making the voltage LOW   

  Servo.attach(servoPin2);                  //We need to attach the servo to the used pin number

  Servo.write(60);                          //Linear motion of cutter

  Servo.write(120);                         //Servo motor 2 goes from 60 degree to 120 degrees and then back to 60 degree 

  delay(1500);                             //Wait for 1.5 seconds

  Servo.write(60); 

  delay(1500);                            //Wait for 1.5 seconds

}

⚠️ **GitHub.com Fallback** ⚠️