Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions servo_latest.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#include <Servo.h>
char data = 0;
int a=5;
int b=6;
int c=10;
int d=3;
int e=9;
Servo myservo1;
Servo myservo2;
Servo myservo3;
Servo myservo4;
Servo myservo5;
//Variable for storing received data
void setup()
{
Serial.begin(9600); //Sets the data rate in bits per second (baud) for serial data transmission
myservo1.attach(a);
myservo2.attach(b);
myservo3.attach(c);
myservo4.attach(d);
myservo5.attach(e);
//Sets digital pin 13 as output pin
}
void loop()
{
if(Serial.available() > 0) // Send data only when you receive data:
{
data = Serial.read(); //Read the incoming data and store it into variable data
Serial.print(data); //Print Value inside data in Serial monitor
Serial.print("\n"); //New line
if(data == '1'){ //Checks whether value of data is equal to 1
myservo1.write(180);
}//If value is 1 then LED turns ON
else if(data == '2'){ //Checks whether value of data is equal to 0
myservo1.write(0);
}//If value is 0 then LED turns OFF
else if(data == 'c'){
myservo2.write(180);
}

else if(data == 'd'){
myservo2.write(0); }
else if(data == 'e'){
myservo3.write(180);
}

else if(data == 'f'){
myservo3.write(0); }
else if(data == 'g'){
myservo4.write(180);
}

else if(data == 'h'){
myservo4.write(0); }
else if(data == 'i'){
myservo5.write(180);
}

else if(data == 'j'){
myservo5.write(0); }

}}