LOGIN
John Rodrigues
Mechanical Engineer |certified professional in product design and analysis |MEP Engineer|blogger at designwithjohn.com (Project Leader)
聽路聽Honnavar,聽India
Edit
Delete
Share
Report
Contributions
Sagar Shubham

Sagar has worked with us and have done detailed observation for our project and he has taken lots of efforts to come up with a code.

Sagar is the brain of our robot.

Thank you sagar. I appreciate your help 馃槂

added by:聽聽John Baptist Rodrigues
8likes
Like
Share
Load聽1聽previous comments
Awais Khawar
Btech Electronic and Telecom is in progress
聽路聽Peshawar,聽Pakistan
Edit
Delete
Share
Report
int inp1 =2;
int inp2 =3;
int inp3 =4;
int inp4 =5;
const int pingPin = 7;
void setup() {
  Serial.begin(9600);
  pinMode(inp1, OUTPUT);
  pinMode(inp2, OUTPUT);
  pinMode(inp3, OUTPUT);
  pinMode(inp4, OUTPUT);
}
void loop() {
  //---------This section is for Distance ----------------------------------------------------
  long duration, inches, cm;
  pinMode(pingPin, OUTPUT);
  digitalWrite(pingPin, LOW);
  delayMicroseconds(2);
  digitalWrite(pingPin, HIGH);
  delayMicroseconds(5);
  digitalWrite(pingPin, LOW);
  pinMode(pingPin, INPUT);
  duration = pulseIn(pingPin, HIGH);
  inches = microsecondsToInches(duration);
  cm = microsecondsToCentimeters(duration);
  Serial.print(inches);
  Serial.print("in, ");
  Serial.print(cm);
  Serial.print("cm");
  Serial.println();
  delay(100);
  //-------------this secton is for motor logic-------------------------------------------------
  if(cm < 10)
{
  digitalWrite(inp1, LOW);
  digitalWrite(inp2, HIGH);
  digitalWrite(inp3, HIGH);
  digitalWrite(inp4, LOW);
  delay(500);
}
if(cm == 10)
{
  digitalWrite(inp1, LOW);
  digitalWrite(inp2, LOW);
  digitalWrite(inp3, HIGH);
  digitalWrite(inp4, LOW);
  delay(500);
}
if(cm < 10)
{
  digitalWrite(inp1, LOW);
  digitalWrite(inp2, HIGH);
  digitalWrite(inp3, LOW);
  digitalWrite(inp4, LOW);
  delay(500);
}
}

long microsecondsToInches(long microseconds) {
  return microseconds / 74 / 2;
}
long microsecondsToCentimeters(long microseconds) {
  return microseconds / 29 / 2;


}
1like
Awais Khawar
Btech Electronic and Telecom is in progress
聽路聽Peshawar,聽Pakistan
Edit
Delete
Share
Report

this code is according to this logic table

John Baptist Rodrigues chek this and tell me

0like
Awais Khawar
Btech Electronic and Telecom is in progress
聽路聽Peshawar,聽Pakistan
Edit
Delete
Share
Report

it clean room like this

0like
Ashish Gupta
Engineer
聽路聽Ghaziabad,聽India
Edit
Delete
Share
Report

Awais I want to know about Pingpin. you are considering a sensor? what type? you are creating high to low pulse and then reading it鈥laborate please.

0like
Awais Khawar
Btech Electronic and Telecom is in progress
聽路聽Peshawar,聽Pakistan
Edit
Delete
Share
Report

If you open arduino program

Go to example
Then
Sencers
Open ping example

I put the code from there

0like
John Rodrigues
Mechanical Engineer |certified professional in product design and analysis |MEP Engineer|blogger at designwithjohn.com (Project Leader)
聽路聽Honnavar,聽India
Edit
Delete
Share
Report

Hey Awais
Thanks alot
I鈥檒l check it
Been busy with fabricating
Can please send me the circuit for ?

0like
Leave a reply...
DISCOVER
CHAT
ALERTS
-2
DISCUSSIONS
-1
FEED