LOGIN
John Rodrigues
Mechanical Design Engineer |Founder of designwithjohn.com (Project Leader)
 · HonnavarIndia
Share
Get Link
Report
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 😃

added by:   John Baptist Rodrigues
8 likes 
Like
Award Contribution
Load 1 previous comments
Awais Khawar
Btech Electronic and Telecom is in progress
 · PeshawarPakistan
Share
Get Link
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;


}
1 like 
Awais Khawar
Btech Electronic and Telecom is in progress
 · PeshawarPakistan
Share
Get Link
Report

this code is according to this logic table

John Baptist Rodrigues chek this and tell me

0 like 
Awais Khawar
Btech Electronic and Telecom is in progress
 · PeshawarPakistan
Share
Get Link
Report

it clean room like this

0 like 
Ashish Gupta
Engineer
 · GhaziabadIndia
Share
Get Link
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…elaborate please.

0 like 
Awais Khawar
Btech Electronic and Telecom is in progress
 · PeshawarPakistan
Share
Get Link
Report

If you open arduino program

Go to example
Then
Sencers
Open ping example

I put the code from there

0 like 
John Rodrigues
Mechanical Design Engineer |Founder of designwithjohn.com (Project Leader)
 · HonnavarIndia
Share
Get Link
Report

Hey Awais
Thanks alot
I’ll check it
Been busy with fabricating
Can please send me the circuit for ?

0 like 
Leave a reply...
DISCOVER
CHAT
ALERTS
DISCUSSIONS
FEED