Robotcar Controlled Utilizing G-Sensor Cell phone
Robotcar Controlled Utilizing G-Sensor Cell phone
Make a robot vehicle, which will be controlled from a cell phone utilizing the G-Sensor. Utilize the RemoteXY administration to make GUI and source code!
Equipment segments
- Arduino UNO
- HC-06 Bluetooth Module
- Engine driver chip L298N
- Any robot vehicle stage
Programming applications and online administrations
- RemoteXY
Stage 1.
Construct robotcar utilizing any accessible stage based on two-wheel circuit. Association graph of electronic segments is appeared in the figure underneath. You will require Arduino UNO or agreeable board, Bluetooth HC-05 (06) module, engine driver, and force supply battery. Stuff engines are put on the stage and power to move robot wheels.
step 2.
Go to RemoteXY administration site on http://remotexy.com/ en/ supervisor/and make a graphical UI to control the robot. Set a control include utilizing the G-sensor for joystick. An illustration of interface is in the figure beneath. Snap the catch "Get source code".
step 3.
Download the source code of GUI and open it in Arduino IDE. For arrangement you need RemoteXY.h library; the library can be downloaded from the connection http://remotexy.com/en/library/. You would already be able to attempt to stack code in Arduino and interface with portable application. Be that as it may, while this is just the code clear, at that point you should add required usefulness connecting a graphical interface and engine driver.
step 4.
At that point you need to add robot control usefulness to the source code utilizing a graphical interface. For this reason the field RemoteXY structure. RemoteXY structure shows the entirety of your GUI controls.
The subsequent source code is demonstrated as follows. You can arrange it and transfer it to Arduino.
step5.
Introduce a portable application RemoteXY on http://remotexy.com/en/download/. At the point when the application is running on a cell phone, press Bluetooth button association in the rundown, select the name of your Bluetooth module, for HC-05 (06) modules the name regularly will be INVOR or HC-06.
/////////////////////////////////////////////
// RemoteXY include library //
/////////////////////////////////////////////
/* RemoteXY select connection mode and include library */
#define REMOTEXY_MODE__SOFTWARESERIAL
#include <SoftwareSerial.h>
#include <RemoteXY.h>
/* RemoteXY connection settings */
#define REMOTEXY_SERIAL_RX 2
#define REMOTEXY_SERIAL_TX 3
#define REMOTEXY_SERIAL_SPEED 9600
/* RemoteXY configurate */
unsigned char RemoteXY_CONF[] =
{ 3,0,23,0,1,5,5,15,41,11
,43,43,1,2,0,6,5,27,11,5
,79,78,0,79,70,70,0 };
/* this structure defines all the variables of your control interface */
struct {
/* input variable */
signed char joystick_1_x; /* =-100..100 x-coordinate joystick position */
signed char joystick_1_y; /* =-100..100 y-coordinate joystick position */
unsigned char switch_1; /* =1 if switch ON and =0 if OFF */
/* other variable */
unsigned char connect_flag; /* =1 if wire connected, else =0 */
} RemoteXY;
/////////////////////////////////////////////
// END RemoteXY include //
/////////////////////////////////////////////
/* defined the right motor control pins */
#define PIN_MOTOR_RIGHT_UP 7
#define PIN_MOTOR_RIGHT_DN 6
#define PIN_MOTOR_RIGHT_SPEED 10
/* defined the left motor control pins */
#define PIN_MOTOR_LEFT_UP 5
#define PIN_MOTOR_LEFT_DN 4
#define PIN_MOTOR_LEFT_SPEED 9
/* defined the LED pin */
#define PIN_LED 13
/* defined two arrays with a list of pins for each motor */
unsigned char RightMotor[3] =
{PIN_MOTOR_RIGHT_UP, PIN_MOTOR_RIGHT_DN, PIN_MOTOR_RIGHT_SPEED};
unsigned char LeftMotor[3] =
{PIN_MOTOR_LEFT_UP, PIN_MOTOR_LEFT_DN, PIN_MOTOR_LEFT_SPEED};
/*
speed control of the motor
motor - pointer to an array of pins
v - motor speed can be set from -100 to 100
*/
void Wheel (unsigned char * motor, int v)
{
if (v>100) v=100;
if (v<-100) v=-100;
if (v>0) {
digitalWrite(motor[0], HIGH);
digitalWrite(motor[1], LOW);
analogWrite(motor[2], v*2.55);
}
else if (v<0) {
digitalWrite(motor[0], LOW);
digitalWrite(motor[1], HIGH);
analogWrite(motor[2], (-v)*2.55);
}
else {
digitalWrite(motor[0], LOW);
digitalWrite(motor[1], LOW);
analogWrite(motor[2], 0);
}
}
void setup()
{
/* initialization pins */
pinMode (PIN_MOTOR_RIGHT_UP, OUTPUT);
pinMode (PIN_MOTOR_RIGHT_DN, OUTPUT);
pinMode (PIN_MOTOR_LEFT_UP, OUTPUT);
pinMode (PIN_MOTOR_LEFT_DN, OUTPUT);
pinMode (PIN_LED, OUTPUT);
/* initialization module RemoteXY */
RemoteXY_Init ();
}
void loop()
{
/* event handler module RemoteXY */
RemoteXY_Handler ();
/* manage LED pin */
digitalWrite (PIN_LED, (RemoteXY.switch_1==0)?LOW:HIGH);
/* manage the right motor */
Wheel (RightMotor, RemoteXY.joystick_1_y - RemoteXY.joystick_1_x);
/* manage the left motor */
Wheel (LeftMotor, RemoteXY.joystick_1_y + RemoteXY.joystick_1_x);
}