Control Servo Motor by Android ADK app.
* ADK Board
* ADK IO Kit
A servo motor is an entirely different story. The servo motor is actually an assembly of four things: a normal DC motor, a gear reduction unit, a position-sensing device (usually a potentiometer—a volume control knob), and a control circuit.
The function of the servo is to receive a control signal that represents a desired output position of the servo shaft, and apply power to its DC motor until its shaft turns to that position. It uses the position-sensing device to determine the rotational position of the shaft, so it knows which way the motor must turn to move the shaft to the commanded position. The shaft typically does not rotate freely round and round like a DC motor, but rather can only turn 200 degrees or so back and forth.
The servo has a 3 wire connection: power, ground, and control. The power source must be constantly applied; the servo has its own drive electronics that draw current from the power lead to drive the motor.
* ADK svn check out http://dev.odroid.com/svn/accessory/trunk/ODROIDAccessoryPWMDemo br
* Bluetooth svn check out http://dev.odroid.com/svn/accessory/trunk/ODROIDBluetoothPWMDemo br
//MotorContol //send command message //msg.what -> command character; //msg.arg1 -> port number; (1 ~ 5) //msg.arg2 -> value (1000 ~ 2000) Message ledUpdate = Message.obtain(uiHandler, what, mPort, value); // ADK case SEND_LETTER_PWM_DUTY: if(accessoryManager.isConnected() == false) { return; } commandPacket[0] = SEND_LETTER_PWM_DUTY; commandPacket[1] = 0; commandPacket[2] = (byte) msg.arg1; value = (short) msg.arg2; commandPacket[3] = (byte) (value >> 8); commandPacket[4] = (byte) value; accessoryManager.write(commandPacket); break; // Bluetooth case SEND_LETTER_PWM_DUTY: if (mCmdSendService.getState() != BluetoothMotorControlService.STATE_CONNECTED) { Toast.makeText(getBaseContext(), R.string.not_connected, Toast.LENGTH_SHORT) .show(); return; } commandPacket[0] = SEND_LETTER_PWM_DUTY; commandPacket[1] = 0; commandPacket[2] = (byte) msg.arg1; value = (short) msg.arg2; commandPacket[3] = (byte) (value >> 8); commandPacket[4] = (byte) value; mCmdSendService.write(commandPacket); break;
send 5 byte buffers by bluetooth or usb