Im following the instruction how to solve the problem according to :
http://tutorial.cytron.com.my/2015/09/0 ... interrupt/
However, my servo is still slightly shake and receive data becomes slower.
Im doing a project to communicate between 2 arduino boards via Bluetooth . I want to control servo by potentiometer via Bluetooth.
+Master ( Uno board) connects with potentiometer and then Master sends data to Slaver.
+Slaver ( Mega board) connects with servo and control servo whenever it receives the data from slaver.
+ In my slaver, I wire bluetooth Rx pin and Tx pin to Pin 10 and Pin 11 of Mega respectively.
In my code, I try to set detach and make delay >800. However, the servo just shakes one time / s and the process of receiving data is slower.
Here my RX code
- CODE: SELECT_ALL_CODE
#include <SoftwareSerial.h>
#include <Servo.h>
#define BT_SERIAL_TX 10
#define BT_SERIAL_RX 11
SoftwareSerial BluetoothSerial(BT_SERIAL_TX, BT_SERIAL_RX);
Servo myservo;
int val;
int array[2];
void setup()
{
Serial.begin(9600);
BluetoothSerial.begin(9600);
}
void loop()
{
myservo.detach();
int incoming = BluetoothSerial.read();
myservo.attach(7);
if (BluetoothSerial.available()>0){
array[0]= BluetoothSerial.parseInt();
myservo.write(array[0]);
Serial.println(array[0]);
delay(1000);
}
}
In I know it is wrong to post a completed code accordig to rules in Cytron forum, but I want to make sure that it is easier to helpers.
Sincere thanks in advance