Created
October 15, 2018 05:28
-
-
Save elktros/3ff07d511413241c4c722a941d406275 to your computer and use it in GitHub Desktop.
Code for the project "Bluetooth Controlled Servo Motor using Arduino".
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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