I have seen code using an accelometer sensor, and there are no left or right buttons on the UI of the Android but the RC car can still turn left or right by tilting the Android to the desired direction. Is it possible to do so using buttons?
I've searched online and found this example;
public void leftClick(View v) {
mInstructionList.add(new Instruction(InstructionCommand.LEFT));
mListAdapter.notifyDataSetChanged();
}
public void rightClick(View v) {
mInstructionList.add(new Instruction(InstructionCommand.RIGHT));
mListAdapter.notifyDataSetChanged();
}
public void forwardClick(View v) {
mInstructionList.add(new Instruction(InstructionCommand.FORWARD));
mListAdapter.notifyDataSetChanged();
}
public void reverseClick(View v) {
mInstructionList.add(new Instruction(InstructionCommand.REVERSE));
mListAdapter.notifyDataSetChanged();
}
public void stopClick(View v) {
mInstructionList.add(new Instruction(InstructionCommand.STOP));
mListAdapter.notifyDataSetChanged();
}
Is this correct? And how can the Arduino recognise the button click from Android?