//creating for loop
//Add the Servo library. This is a standard library
#include <Servo.h>
//Define our servos
Servo servo1;
Servo servo2;
Servo servo3;
Servo servo4;
Servo servo5;
//Servo position in degrees
int serPos = 0;
void setup() {
// Define servo signal inputs (Digital PMW 3-5-6-9-10)
servo1.attach(3);
servo2.attach(5);
servo3.attach(6);
servo4.attach(9);
servo5.attach(10);
}
// Initialize serial communication for Bluetooth
Serial.begin(9600);
// Inform the user that setup is complete
Serial.println("Bluetooth module is ready.");
}
void loop() {
if (Serial.available() > 0) {
char command = Serial.read();
// Example: Controlling servos based on Bluetooth commands
if (command == 'A') {
servo1.write(90); // Move servo1 to 90 degrees
} else if (command == 'B') {
servo2.write(90); // Move servo2 to 90 degrees
} else if (command == 'C') {
servo3.write(90); // Move servo3 to 90 degrees
} else if (command == 'D') {
servo4.write(90); // Move servo4 to 90 degrees
} else if (command == 'E') {
servo5.write(90); // Move servo5 to 90 degrees
}
// Debugging output
Serial.print("Received command: ");
Serial.println(command);
}
}