Instructables

Reverse Engineering =Uzzors2k= Bluecar Android App. Amarino Stuff Too.

Step 1: Amarino

Here's my amarino code if you wanted to take a look. Don't laugh, please just give me some constructive criticism. 
I'm using a rooted HTC inspire. 
go to http://www.amarino-toolkit.net/index.php/download.html for more info.

I was experimenting with the switch case to try and get faster response times. do what ever you want. there used to be an if statement there.

I actually modified somebody's code off the internet, so some things seem arbitrary. (I hope I didn't use that word wrong..)
Your going to have to download the Amarino library for the Arduino IDE off their website. 

#include <MeetAndroid.h>
#include <Servo.h>

MeetAndroid meetAndroid;
Servo myservo;       //controls the steering
Servo motor;            //controls the for/rev motor

void setup()
{
Serial.begin(9600);     //default baud rate for bt module
meetAndroid.registerFunction(phoneorient, 'A');   //use event A in amarino
myservo.attach(9); //servo
motor.attach(8); //forward/backwards motor
}

void loop()
{
meetAndroid.receive(); // you need to keep this in your loop() to receive events
}

void phoneorient(byte flag, byte numOfValues)
{
//Phone Orientation Controller
int values[]={0,0,0};
meetAndroid.getIntValues(values);

// You must hold phone in LANDSCAPE for following orientation.
double x=values[1];     //store x as a double (long decimal number)
int y=values[2];
int z=values[3];
x = (-x);           //my steering was reversed, quick fix
if (x>2)
{
myservo.write(105 + (x-2)*2.5);  //values determined by trial and error for my car
}
else if (x< -2)
{
myservo.write(105 + (x+2)*3.571);  //unique for my car

}
else
{
myservo.write(105);        //unique center steering position
}
/* if (y>=7)
{
//motor.write(180);
motor.write(90 + 25*(y-7));
} */

switch (y)       //tried to use a switch statement so that the motor was faster, reverse is a little glitchy I recommend using the if statement                           //anyways. If you do use the if, change y to a float/double instead of int. 
{
case 9:
motor.write(180);
break;
case 8:
motor.write(150);
break;
case 7:
motor.write(120);
break;
case 6:
case 5:
case 4:
case 3:
case 2:
case 1:
case 0:
motor.write(90);
break;
case -1:
case -2:
case -3:
case -4:
case -5:
case -6:
case -7:
case -8:
case -9:
motor.write(30);
break;
}
/*else if (y<1)
{
motor.write(90 - (y-1)*);
//motor.write(30);
}
else
{
motor.write(90);
}*/
 
Remove these adsRemove these ads by Signing Up