Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save elktros/3ff07d511413241c4c722a941d406275 to your computer and use it in GitHub Desktop.
Save elktros/3ff07d511413241c4c722a941d406275 to your computer and use it in GitHub Desktop.
Code for the project "Bluetooth Controlled Servo Motor using Arduino".
#include<SoftwareSerial.h>
#include <Servo.h>
Servo myservo;
SoftwareSerial mySerial(2, 3); // RX, TX
int Position ;
void setup()
{
myservo.attach(11);
mySerial.begin(9600);
Serial.begin(9600);
}
void loop()
{
if(mySerial.available()>0)
{
Position = mySerial.read();
Position = map(Position, 0, 180, 180, 0);
myservo.write(Position);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment