I want to send five data to Bluetooth. First one is turn on and second one is turn off, third one is turn on, and so on... I want post delay between turn on and turn off (about 1 second). Which is best one to do it. Currently, I am using sleep in Thread class
for (int i=1;i<5;i++) {
try {
if(i%2==0){
send(1);
Thread.sleep(500);
}
else{
send(0);
Thread.sleep(500);
}
} catch (InterruptedException e) {
e.printStackTrace();
}
}