Hello everyone i have constructed an arduino board fit with a bluetooth module and an servo, everything was going good until i connected the bluetooth with the android app, im supposed to control the angle the servo is at but can't. Furthermore, if i try to move the servo it won't budge its literally stuck in place when i load the code.
the project
i have all the supplies he mentioned not whats on the board exactly.
the code (where i think the problem lies)
#include <Servo.h>
Servo myservo; // create servo object to control a servo
// a maximum of eight servo objects can be created
int pos = 0; // variable to store the servo position
int motor = 0;
void setup()
{
Serial.begin(9600); // initialize serial:
myservo.attach(9); // attaches the servo on pin 9 to the servo object
Serial.print("Arduino control Servo Motor Connected OK");
Serial.print('\n');
}
void loop()
{
// if there's any serial available, read it:
while (Serial.available() > 0) {
// look for the next valid integer in the incoming serial stream:
motor = Serial.parseInt();
// do it again:
pos = Serial.parseInt();
// look for the newline. That's the end of your sentence:
if (Serial.read() == '\n') {
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
// print the three numbers in one string as hexadecimal:
Serial.print("Data Response : ");
Serial.print(motor, DEC);
Serial.print(pos, DEC);
}
}
}
i believe that somewhere in the code there is an error, i uploaded successfully with nothing in the tx rx pins and reconnected them, connected to bluetooth on the app but the rotation is not happenening