I am building a robot with 12 Servos. (5 for each arm, and 2 for the head.)
I have built a control box containing 12 Potentiometers and HC-05 Bluetooth Module connected to Arduino Mega.
The robot is 12 Servos connected to another Arduino Mega with its own Bluetooth Module.
My goal is this: Turn potentiometer 1 and servo 1 moves, turn potentiometer 2 and servo 2 moves. and so on.......
I found some code online but the problem is, it is only for 1 servo.
I can't figure out how to send multiple potentiometer values at the same time.
I hope this isn't a stupid question but i need to finish this project in the next week, so please help.
//control box
#include <Servo.h>
Servo myServo;
int state = 20;
void setup() {
myServo.attach(9);
Serial.begin(9600);
}
void loop() {
if(Serial.available() > 0){
state = Serial.read();
}
myServo.write(state);
delay(10);
}
//robot
int potValue = 0;
void setup() {
Serial.begin(9600);
}
void loop() {
potValue = analogRead(A0);
int potValueMapped = map(potValue, 0, 1023, 0, 255);
Serial.write(potValueMapped);
delay(10);
}
1_Servo_Bluetooth__control_box.ino|attachment (247 Bytes)
_1_Servo_Bluetooth_Robot.ino (213 Bytes)