Hi, i did this project for my project. i have shared the link below.
[/img]Aircraft auto taxi parking system @ RP - YouTube
Now i have to upgrade this and attach a bluetooth module to it to sent the route plan through a android app. I have att the bluetooth but when i try sent the old codes(not using android app) the arduino does not follow according to the codes, it just follows the black line. Is there anything i must add to the codes for it to read from the bluetooth module??
I have connected pins :
RX(from bluetooth) - pin4
TX(from bluetooth) - pin3
vcc(from bluetooth) - 5.5V
gnd- gnd
I am using a arduino uno board.I have also attached the codes below. PLEASE HELP ME. ITS VERY URGENT. I NEED SUBMIT IN 10 DAYS!!!!
//online resources and library :
#include <QTRSensors.h>
#include <ZumoReflectanceSensorArray.h>
#include <ZumoMotors.h>
#define LED_PIN 13
// Change record
// Change second left turn (m= 2) to go forward before left turn.
ZumoMotors motors;
ZumoReflectanceSensorArray reflectanceSensors;
// Define an array for holding sensor values.
#define NUM_SENSORS 6
unsigned int sensorValues[NUM_SENSORS];
int proportional= 0;
int integral=0;
int last_proportional=0;
int derivative=0;
float K1, K2, K3;
float error_value;
int m = 0;
int s;
int wait = 2500; // Standard junction wait time
void setup()
{
s= 70;
reflectanceSensors.init();
digitalWrite(2, LOW);
delay(500);
pinMode(13, OUTPUT);
digitalWrite(13, HIGH); // turn on LED to indicate we are in calibration mode
unsigned long startTime = millis();
while(millis() - startTime < 10000) // make the calibration take 10 seconds
{
reflectanceSensors.calibrate();
}
digitalWrite(13, LOW); // turn off LED to indicate we are through with calibration
// print the calibration minimum values measured when emitters were on
Serial.begin(9600);
for (byte i = 0; i < NUM_SENSORS; i++)
{
Serial.print(reflectanceSensors.calibratedMinimumOn[i]);
Serial.print(' ');
}
Serial.println();
// print the calibration maximum values measured when emitters were on
for (byte i = 0; i < NUM_SENSORS; i++)
{
Serial.print(reflectanceSensors.calibratedMaximumOn[i]);
Serial.print(' ');
}
Serial.println();
Serial.println();
delay(1000);
}
void sensor()
{
// read calibrated sensor values and obtain a measure of the line position.
// Note: the values returned will be incorrect if the sensors have not been properly
// calibrated during the calibration phase.
unsigned int position = reflectanceSensors.readLine(sensorValues);
// To get raw sensor values instead, call:
//reflectanceSensors.read(sensorValues);
for (byte i = 0; i < NUM_SENSORS; i++)
{
Serial.print(sensorValues[i]);
Serial.print(' ');
}
Serial.print(" ");
Serial.println(position);
delay(250);
}
//code down by Song Hui. PID CONTROL
void turn() {
unsigned int position = reflectanceSensors.readLine(sensorValues);
float K1 = 0.1;
float K2 = 0;
float K3 = 0;
proportional = position - 2450;
integral = integral + proportional;
derivative = proportional - last_proportional;
last_proportional = proportional;
error_value = proportional* K1 + integral * K2 + derivative *K3;
Serial.print(' ');
Serial.print(proportional);
Serial.print(' ');
Serial.print(integral);
Serial.print(' ');
Serial.print(derivative);
Serial.print(' ');
Serial.print(error_value);
Serial.print(' ');
if (error_value < - s) {
error_value = -s;
}
if (error_value > s) {
error_value = s;
}
if (error_value <0 ) {
motors.setRightSpeed(-s +error_value );
motors.setLeftSpeed(-s -error_value );
}
else {
motors.setRightSpeed(-s +error_value);
motors.setLeftSpeed(-s - error_value);
}
}
//what should the car do when it meets the junctions and how it gonna remember it
void loop(){
unsigned int position = reflectanceSensors.readLine(sensorValues);
// **************** Comment out the first Y junction, to place the car after it
// if (sensorValues[0] > 50 and sensorValues[5] < 50 and m==0){
// motors.setRightSpeed(0);
// motors.setLeftSpeed(0);
// delay(wait);
//
// motors.setRightSpeed(-s);
// motors.setLeftSpeed(-s);
// delay(1200);
// m=m+1;
//
// turn();
// }
// *******************************************************************
if (sensorValues[0] > 50 and sensorValues[5] < 50 and m==0){
motors.setRightSpeed(0);
motors.setLeftSpeed(0);
delay(wait);
// ************** Insert move forward to clear the grass patch on left, with a more aggressive turn
motors.setRightSpeed(-s);
motors.setLeftSpeed(-s);
delay(700);
// ****************
motors.setRightSpeed(-180); // change from -130
motors.setLeftSpeed(80);
delay(600);
motors.setRightSpeed(-50);
motors.setLeftSpeed(-50);
delay(2000);
motors.setRightSpeed(-50);
motors.setLeftSpeed(30);
delay(450);
m=m+1;
turn();
}
if (sensorValues[0] > 50 and sensorValues[5] > 50 and m==1){
motors.setRightSpeed(0);
motors.setLeftSpeed(0);
delay(wait);
motors.setRightSpeed(-s);
motors.setLeftSpeed(-s);
delay(1200);
m=m+1;
turn();
}
if (sensorValues[0] > 50 and sensorValues[5] > 50 and m==2){
motors.setRightSpeed(0);
motors.setLeftSpeed(0);
delay(wait);
// *********** Change in Rev 2 to move forward x msec before turning ***************
motors.setRightSpeed(-s);
motors.setLeftSpeed(-s);
delay(1200);
// **********************************************************************************
motors.setRightSpeed(-200); // change from -130
motors.setLeftSpeed(100);
delay(1000);
motors.setRightSpeed(-50);
motors.setLeftSpeed(30);
delay(1200);
motors.setRightSpeed(-50);
motors.setLeftSpeed(-50);
delay(500);
m=m+1;
turn();
}
if (sensorValues[0] > 50 and sensorValues[5] > 50 and m==3){
motors.setRightSpeed(0);
motors.setLeftSpeed(0);
delay(wait);
// *********** Change in Rev 2 to move forward 300msec before turning ***************
motors.setRightSpeed(-s);
motors.setLeftSpeed(-s);
delay(850);
motors.setLeftSpeed(-150); // change from -130
motors.setRightSpeed(80);
delay(2000);
// Added straight
motors.setRightSpeed(-80);
motors.setLeftSpeed(-80);
delay(1500); // change from 1500
motors.setRightSpeed(20);
motors.setLeftSpeed(-90);
delay(1200);
m=m+1;
turn();
}
if (sensorValues[0] > 50 and sensorValues[5] > 50 and m==4){
motors.setRightSpeed(0);
motors.setLeftSpeed(0);
delay(wait);
motors.setRightSpeed(-s);
motors.setLeftSpeed(-s);
delay(1200);
m=m+1;
turn();
}
if (sensorValues[0] > 50 and sensorValues[5] > 50 and m==5){
motors.setRightSpeed(0);
motors.setLeftSpeed(0);
delay(30000);
m=0;
}
else{
turn();
}
}
If you are in singapore, and can meet me to help, my number is 92210765!! PLEASE HELP!!