LOGIN
John Rodrigues
50
Community Expert
Mechanical Design Engineer |Founder of designwithjohn.com (Project Leader)
聽路聽Honnavar,聽India
Share
Report
Get Link
STATUS
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 馃槂

8likes
Like
Award Contribution
Load聽1聽previous comments
Awais Khawar
1
Apprentice
Btech Electronic and Telecom is in progress
聽路聽Peshawar,聽Pakistan
Share
Report
Get Link
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;


}
Like
1like
Award Contribution
Awais Khawar
1
Apprentice
Btech Electronic and Telecom is in progress
聽路聽Peshawar,聽Pakistan
Share
Report
Get Link

this code is according to this logic table

John Baptist Rodrigues chek this and tell me

Like
0like
Award Contribution
Awais Khawar
1
Apprentice
Btech Electronic and Telecom is in progress
聽路聽Peshawar,聽Pakistan
Share
Report
Get Link

it clean room like this

Like
0like
Award Contribution
Engineer
聽路聽Ghaziabad,聽India
Share
Report
Get Link

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.

Like
0like
Award Contribution
Awais Khawar
1
Apprentice
Btech Electronic and Telecom is in progress
聽路聽Peshawar,聽Pakistan
Share
Report
Get Link

If you open arduino program

Go to example
Then
Sencers
Open ping example

I put the code from there

Like
0like
Award Contribution
John Rodrigues
50
Community Expert
Mechanical Design Engineer |Founder of designwithjohn.com (Project Leader)
聽路聽Honnavar,聽India
Share
Report
Get Link

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

Like
0like
Award Contribution
Leave a reply...
DISCOVER
CHAT
ALERTS
DISCUSSIONS
FEED