I am using a android app to control a servo motor through a arduino nano which communicates to the app through a HC-05 bluetooth module but i want to power the nano with a battery so the serial functions do not work and i cant find a way to use bluetoooth without serial communication.
Thanks if you can help.
Code:
#include <Servo.h>
Servo myservo;
int pos = 180;
void setup() {
myservo.attach(9);
Serial.begin(9600);
myservo.write(pos);
}
void loop() {
if (Serial.available()>0){
char data = Serial.read();
Serial.println(data);
if (data == 'u'){
pos -= 5;
if (pos < 0){
pos = 0;
myservo.write(pos);
}
else{
myservo.write(pos);
}
}
else{
delay(1);
}
if (data == 'd'){
pos += 5;
if (pos > 180){
pos = 180;
myservo.write(pos);
}
else{
myservo.write(pos);
}
}
else{
delay(1);
}
}
}