Go Down

Topic: pay for help me i will add two extra senesor (Read 619 times) previous topic - next topic

sosolone

i have problem
i will add two sensors extra

but not have any idea about write code

any person can help me pls write code

i mean add the new code  in my code:(note: my code work with one  sensor very good):


include <Servo.h> //servo library
Servo myservo; // create servo object to control servo
int Echo = A4;
int Trig = A5;
int in1 = 6;
int in2 = 7;
int in3 = 8;
int in4 = 9;
int ENA = 5;
int ENB = 11;
int ABS = 110;
int rightDistance = 0,leftDistance = 0,middleDistance = 0 ;
void _mForward()
{
analogWrite(ENA,ABS);
analogWrite(ENB,ABS);
digitalWrite(in1,LOW);
digitalWrite(in2,HIGH);
digitalWrite(in3,LOW);
digitalWrite(in4,HIGH);
Serial.println("go forward!");
}
void _mBack()
{
analogWrite(ENA,ABS);
analogWrite(ENB,ABS);
digitalWrite(in1,LOW);
digitalWrite(in2,HIGH);
digitalWrite(in3,HIGH);
digitalWrite(in4,LOW);
Serial.println("go back!");
}
void _mleft()
{
analogWrite(ENA,ABS);
analogWrite(ENB,ABS);
digitalWrite(in1,LOW);
digitalWrite(in2,HIGH);
digitalWrite(in3,HIGH);
digitalWrite(in4,LOW);
Serial.println("go left!");
}
void _mright()
{
analogWrite(ENA,ABS);
analogWrite(ENB,ABS);
digitalWrite(in1,HIGH);
digitalWrite(in2,LOW);
digitalWrite(in3,LOW);
digitalWrite(in4,HIGH);
Serial.println("go right!");
}
void _mStop()
{
digitalWrite(ENA,LOW);
digitalWrite(ENB,LOW);
Serial.println("Stop!");
}
/*Ultrasonic distance measurement Sub function*/
int Distance_test()
{
digitalWrite(Trig, LOW);
delayMicroseconds(2);
digitalWrite(Trig, HIGH);
delayMicroseconds(20);
digitalWrite(Trig, LOW);
float Fdistance = pulseIn(Echo, HIGH);
Fdistance= Fdistance/58;
return (int)Fdistance;
}
void setup()
{
myservo.attach(3);// attach servo on pin 3 to servo object
Serial.begin(9600);
pinMode(Echo, INPUT);
pinMode(Trig, OUTPUT);
pinMode(in1,OUTPUT);
pinMode(in2,OUTPUT);
pinMode(in3,OUTPUT);
pinMode(in4,OUTPUT);
pinMode(ENA,OUTPUT);
pinMode(ENB,OUTPUT);
_mStop();
}
void loop()
{
myservo.write(90);//setservo position according to scaled value
delay(500);
middleDistance = Distance_test();
#ifdef send
Serial.print("middleDistance=");
Serial.println(middleDistance);
#endif
if(middleDistance<=20)
{
_mStop();
delay(500);
myservo.write(5);
delay(1000);
rightDistance = Distance_test();
#ifdef send
Serial.print("rightDistance=");
Serial.println(rightDistance);
#endif
delay(500);
myservo.write(90);
delay(1000);
myservo.write(180);
delay(1000);
leftDistance = Distance_test();
#ifdef send
Serial.print("leftDistance=");
Serial.println(leftDistance);
#endif
delay(500);
myservo.write(90);
delay(1000);
if(rightDistance>leftDistance)
{
_mright();
delay(180);
}
else if(rightDistance<leftDistance)
{
_mleft();
delay(180);
}
else if((rightDistance<=20)||(leftDistance<=20))
{
_mBack();
delay(180);
}
else
{
_mForward();
}
}
else
_mForward();
}








and watch my board in attachment

sosolone

this my car
https://www.youtube.com/watch?v=OzRcspVUcqs

luisilva

How much do you will pay? What are the conditions for the new 2 sensors?

sosolone

How much do you will pay? What are the conditions for the new 2 sensors?
no conditions only i will add in front
and do same the first sensor
but the two extra without motor
i mean only paste it in front

sosolone


patduino

Sosolone,

Can you explain to the forum what you want the additional sensors to control? I'm sure someone can add them, but they may not know what else you are asking for...

Are they controlling identical servos?
There are 10 types of people in the world, those who understand binary, and those that don't.

sosolone

#6
Nov 18, 2016, 10:35 am Last Edit: Nov 18, 2016, 10:43 am by sosolone
i will add style only( i mean any person see it say 3 sesnor)

i mean the goal like the first sensor


not any change


i mean only i want it work same the first sensor

https://www.youtube.com/watch?v=OzRcspVUcqs



sosolone

or if you want made like this no problem
https://www.youtube.com/watch?v=mU_SKUSHVlc




and this my car now
https://www.youtube.com/watch?v=AXthqmEmofE



my goal the three sensor work


Go Up