Hello we
We are trying to make servo control circuit with hc 05 bluetooth connection with 6 potentiometers.
but I can control a single servo with the codes we have written.
Could you write me a sample transceiver code?
(footnote: there is a single servo control transceiver code attached for your information)
//TRANSMITTER CODE
#include <SoftwareSerial.h>
#define BT_SERIAL_TX 4
#define BT_SERIAL_RX 3
SoftwareSerial BluetoothSerial(BT_SERIAL_TX, BT_SERIAL_RX);
int potpin = A0;
unsigned int val;
void setup()
{
Serial.begin(9600);
BluetoothSerial.begin(9600);
}
void loop()
{
val = analogRead(potpin);
val = map(val, 0, 1023, 0, 179);
BluetoothSerial.write(val);
//RECEIVER CODE
#include <SoftwareSerial.h>
#define BT_SERIAL_TX 4
#define BT_SERIAL_RX 3
SoftwareSerial BluetoothSerial(BT_SERIAL_TX, BT_SERIAL_RX);
#include <Servo.h>
Servo myservo;
unsigned int val ;
void setup()
{
Serial.begin(9600);
BluetoothSerial.begin(9600);
myservo.attach(10);
}
void loop() // run over and over
{
if (BluetoothSerial.available()>0){
val = BluetoothSerial.read();
myservo.write(val);
}
}
My starting point would be to create an array of pots, and an array of servos.
That will consolidate your code, then once you have one working, you have them all working.
Do not use blocking delay() or while loops, or you’ll start having problems.
Thank you for your reply. Could you send me an example of 5 potentiometers and 5 servo motor control codes via bluetooth?
but our request is like this, we want to control 5 different pots and 5 different servos control with bluetooth