There is a grey label which is fixed to battery pack, on it. If you push it up, there are screws.They need soldering for serial connection.
10 Nisan 2019 Çarşamba
5 Nisan 2019 Cuma
Android Bluetooth Connection To HC-05
Sending Data to HC-05
package com.example.a6dofbt;
import android.app.Activity;
import android.app.ProgressDialog;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothSocket;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.SeekBar;
import android.widget.SeekBar.OnSeekBarChangeListener;
import android.widget.TextView;
import android.widget.Toast;
import java.io.IOException;
import java.io.OutputStream;
import java.util.UUID;
public class dof extends Activity {
private OutputStream outStream = null;
private BluetoothDevice device;
private TextView title;
private SeekBar clamp ;
private SeekBar base;
private SeekBar leg;
private SeekBar waist;
private SeekBar head;
private SeekBar chest;
private EditText motorno;
private Button add;
private Button subtract;
private static final UUID MY_UUID = UUID.fromString("00001101-0000-1000-8000-00805F9B34FB");
private static String address = "00:00:00:00:00:00";
private BluetoothAdapter btAdapter = null;
private BluetoothSocket btSocket = null;
private static final int REQUEST_ENABLE_BT = 1;
private boolean isBtConnected = false;
private ProgressDialog dialog;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.dof);
MotorBar clamp = new MotorBar(0,200, "Clamp");
MotorBar head = new MotorBar(1,200, "Head");
MotorBar chest = new MotorBar(2,200, "Chest");
MotorBar waist = new MotorBar(3,200, "Waist");
MotorBar leg = new MotorBar(4,200, "Leg");
MotorBar base = new MotorBar(5,200, "Base");
clamp.bar = (SeekBar) findViewById(R.id.seekBarOne);
head.bar = (SeekBar) findViewById(R.id.seekBarTwo);
chest.bar = (SeekBar) findViewById(R.id.seekBarThree);
waist.bar = (SeekBar) findViewById(R.id.seekBarFour);
leg.bar = (SeekBar) findViewById(R.id.seekBarFive);
base.bar = (SeekBar) findViewById(R.id.seekBarSix);
clamp.text = (TextView) findViewById(R.id.textOne);
head.text = (TextView) findViewById(R.id.textTwo);
chest.text = (TextView) findViewById(R.id.textThree);
waist.text = (TextView) findViewById(R.id.textFour);
leg.text = (TextView) findViewById(R.id.textFive);
base.text = (TextView) findViewById(R.id.textSix);
title = (TextView) findViewById(R.id.title);
try {
Bundle b = this.getIntent().getExtras();
address = (String) b.get("address");
title.setText(address);
/*
btAdapter = BluetoothAdapter.getDefaultAdapter();
device = btAdapter.getRemoteDevice(address);
btSocket = device.createInsecureRfcommSocketToServiceRecord(MY_UUID);
BluetoothAdapter.getDefaultAdapter().cancelDiscovery();
btSocket.connect();
outStream = btSocket.getOutputStream();
outStream.write("w".getBytes());
*/
new BTbaglan().execute();
} catch(Exception e) {
errorExit("Error", e.getLocalizedMessage());
}
//checkBTState();
add = (Button) findViewById(R.id.add);
subtract = (Button) findViewById(R.id.subtract);
motorno = (EditText) findViewById(R.id.motorno);
motorno.setText("0");
add.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
try {
String mno = String.valueOf(motorno.getText());
outStream.write(mno.getBytes());
outStream.flush();
Thread.sleep(30);
outStream.write("w".getBytes());
outStream.flush();
} catch(Exception e) {
errorExit("Final Error", "no write on stream "+e.getLocalizedMessage());
}
}
});
subtract.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
try {
String mno = String.valueOf(motorno.getText());
outStream.write(mno.getBytes());
outStream.flush();
Thread.sleep(30);
outStream.write("e".getBytes());
outStream.flush();
} catch(Exception e) {
errorExit("Final Error", "no write on stream for button"+e.getLocalizedMessage());
}
}
});
int maxV = 500;
MotorBar[] motors = {clamp, head, chest, waist, leg, base};
for(int i=0; i < motors.length; i++) {
final MotorBar m = motors[i];
m.bar.setMax(maxV);
m.bar.setProgress(motors[i].value);
m.bar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
int progressValue = 0;
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
progressValue = progress;
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) { }
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
seekBar.setProgress(progressValue);
m.value = progressValue + 50;
m.text.setText(m.name +": "+String.valueOf(m.value));
try {
String mno = String.valueOf(m.no);
outStream.write(mno.getBytes());
outStream.flush();
Thread.sleep(500);
String mv = String.valueOf(m.value);
outStream.write(mv.getBytes());
outStream.flush();
} catch(Exception e) {
errorExit("Fatal Error", "no write on stream for bar "+e.getLocalizedMessage());
}
}
});
}
}
private void errorExit(String title, String message){
Toast msg = Toast.makeText(getBaseContext(),
title + " - " + message, Toast.LENGTH_SHORT);
msg.show();
finish();
}
/*
@Override
public void onPause() {
super.onPause();
if (outStream != null) {
try {
outStream.flush();
} catch (IOException e) {
errorExit("Fatal Error", "In onPause() and failed to flush output stream: " + e.getMessage() + ".");
}
}
try {
btSocket.close();
} catch (IOException e2) {
errorExit("Fatal Error", "In onPause() and failed to close socket." + e2.getMessage() + ".");
}
}
private void checkBTState() {
if(btAdapter==null) {
errorExit("Fatal Error", "Bluetooth Not supported. Aborting.");
} else {
if (!btAdapter.isEnabled()) {
//Prompt user to turn on Bluetooth
Intent enableBtIntent = new Intent(btAdapter.ACTION_REQUEST_ENABLE);
startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT);
}
}
}
@Override
public void onBackPressed() {
super.onBackPressed();
Disconnect();
}
private void Disconnect() {
if(btSocket != null) {
try{
btSocket.close();
} catch (Exception e) {
}
}
finish();
}
@Override
public void onResume() {
super.onResume();
try {
btSocket = device.createRfcommSocketToServiceRecord(MY_UUID);
} catch (IOException e) {
errorExit("Fatal Error", "In onResume() and socket create failed: " + e.getMessage() + ".");
}
btAdapter.cancelDiscovery();
try {
btSocket.connect();
} catch (IOException e) {
try {
btSocket.close();
} catch (IOException e2) {
errorExit("Fatal Error", "In onResume() and unable to close socket during connection failure" + e2.getMessage() + ".");
}
}
try {
outStream = btSocket.getOutputStream();
} catch (IOException e) {
errorExit("Fatal Error", "In onResume() and output stream creation failed:" + e.getMessage() + ".");
}
}
private void setMotor(MotorBar motor) {
String no = String.valueOf(motor.no);
String v = String.valueOf(motor.value);
sendData(no);
try {
Thread.sleep(20);
} catch (InterruptedException e) {
e.printStackTrace();
}
sendData(v);
}
private void sendData(String message) {
byte[] msgBuffer = message.getBytes();
try {
if(!btSocket.isConnected()) {
btSocket = device.createInsecureRfcommSocketToServiceRecord(MY_UUID);
BluetoothAdapter.getDefaultAdapter().cancelDiscovery();
btSocket.connect();
}
outStream.write(msgBuffer);
} catch (IOException e) {
String msg = "Sending data failed" + e.getMessage();
errorExit("Fatal error", msg);
}
}
@Override
protected void onDestroy() {
super.onDestroy();
}
*/
public class BTbaglan extends AsyncTask<Void, Void, Void> {
private boolean ConnectSuccess = true;
@Override
protected void onPreExecute() {
super.onPreExecute();
try {
dialog = ProgressDialog.show(dof.this, "Baglanıyor...", "Lütfen Bekleyin");
} catch(Exception e) {
errorExit2("Fatal error", e.getLocalizedMessage());
}
}
@Override
protected Void doInBackground(Void... devices) {
try {
if (btSocket == null || !isBtConnected) {
btAdapter = BluetoothAdapter.getDefaultAdapter();
BluetoothDevice device = btAdapter.getRemoteDevice(address);
btSocket = device.createInsecureRfcommSocketToServiceRecord(MY_UUID);
BluetoothAdapter.getDefaultAdapter().cancelDiscovery();
btSocket.connect();
outStream = btSocket.getOutputStream();
}
} catch (IOException e) {
ConnectSuccess = false;
} catch(Exception e) {
errorExit2("Fatal error", e.getLocalizedMessage());
}
return null;
}
@Override
protected void onPostExecute(Void result) {
super.onPostExecute(result);
if (!ConnectSuccess) {
// msg("Baglantı Hatası, Lütfen Tekrar Deneyin");
Toast.makeText(getApplicationContext(), "Bağlantı Hatası Tekrar Deneyin", Toast.LENGTH_SHORT).show();
finish();
} else {
// msg("Baglantı Basarılı");
Toast.makeText(getApplicationContext(), "Bağlantı Başarılı", Toast.LENGTH_SHORT).show();
isBtConnected = true;
}
dialog.dismiss();
}
private void errorExit2(String title, String message){
Toast msg = Toast.makeText(getBaseContext(),
title + " - " + message, Toast.LENGTH_SHORT);
msg.show();
}
}
}
15 Mart 2019 Cuma
HC-05 python connection
import bluetooth
print "Searching for devices..."
print ""
nearby_devices = bluetooth.discover_devices()
num = 0
print "Select your device by entering its coresponding number..."
for i in nearby_devices:
num+=1
print num , ": " , bluetooth.lookup_name( i )
selection = input("> ") - 1
print "You have selected", bluetooth.lookup_name(nearby_devices[selection])
bd_addr = nearby_devices[selection]
port = 1
sock = bluetooth.BluetoothSocket( bluetooth.RFCOMM )
sock.connect((bd_addr, port))
print "Everything is OK, Start to write"
while 1:
data = raw_input()
if len(data) == 0: break
sock.send(data)
sock.close()
4 Mart 2019 Pazartesi
Bluetooth 4.0 Arduino At-09
include
SoftwareSerial mySerial(2, 3); // RX, TX
int PIN_EN_OUT = 4;
int PIN_STATE_IN = 5;
void setup() {
// put your setup code here, to run once:
mySerial.begin(9600);
Serial.begin(9600);
Serial.println("start at 09 bt");
sendCommand("AT");
sendCommand("AT+ROLE0");
sendCommand("AT+UUID0xFFE0");
sendCommand("AT+CHAR0xFFE1");
sendCommand("AT+NAMESeloBT");
sendCommand("AT+PIN123456");
}
void sendCommand(const char * command){
Serial.print("Command send :");
Serial.println(command);
mySerial.println(command);
//wait some time
delay(100);
char reply[100];
int i = 0;
while (mySerial.available()) {
reply[i] = mySerial.read();
i += 1;
}
//end the string
reply[i] = '\0';
Serial.print(reply);
Serial.println("Reply end");
}
void readSerial(){
char reply[50];
int i = 0;
while (mySerial.available()) {
reply[i] = mySerial.read();
i += 1;
}
//end the string
reply[i] = '\0';
if(strlen(reply) > 0){
Serial.println(reply);
Serial.println("We have just read some data");
}
}
void loop() {
readSerial();
delay(500);
}
3 Şubat 2019 Pazar
Etac Cross 5 and Alber E-Motion M12 Bracket
My Solution

Download Alber M12 user guide
https://drive.google.com/open?id=1I0sWR_9vtMqcL8J0MUaEfms2IAzNnHtl
Spare parts
https://drive.google.com/open?id=1-9YXah7lEwhhQKlQoKgk5Wi0oT-G9M5a

Download Alber M12 user guide
https://drive.google.com/open?id=1I0sWR_9vtMqcL8J0MUaEfms2IAzNnHtl
Spare parts
https://drive.google.com/open?id=1-9YXah7lEwhhQKlQoKgk5Wi0oT-G9M5a
16 Kasım 2018 Cuma
Bash Ping Test
#!/bin/bash
A=""
for i in {1..30}
do
ping -q -c1 192.168.1.$i
if [ $? -eq 0 ]
then
A+="Ok 192.168.1.$i\n"
else
A+="No 192.168.1.$i\n"
fi
done
echo -e "$A"
Kaydol:
Kayıtlar (Atom)

