LOGIN
John Rodrigues
90
Community Expert
Product Designer|Entrepreneur |Founder of designwithjohn.com (Project Leader)
 · HonnavarIndia
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 :)

8 likes 
Like
Award Contribution
Load 1 previous comments
Awais Khawar
1
Apprentice
Btech Electronic and Telecom is in progress
 · PeshawarPakistan
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
1 like 
Award Contribution
Awais Khawar
1
Apprentice
Btech Electronic and Telecom is in progress
 · PeshawarPakistan
Share
Report
Get Link

this code is according to this logic table

John Baptist Rodrigues chek this and tell me

Like
0 like 
Award Contribution
Awais Khawar
1
Apprentice
Btech Electronic and Telecom is in progress
 · PeshawarPakistan
Share
Report
Get Link

it clean room like this

Like
0 like 
Award Contribution
Engineer
 · GhaziabadIndia
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…elaborate please.

Like
0 like 
Award Contribution
Awais Khawar
1
Apprentice
Btech Electronic and Telecom is in progress
 · PeshawarPakistan
Share
Report
Get Link

If you open arduino program

Go to example
Then
Sencers
Open ping example

I put the code from there

Like
0 like 
Award Contribution
John Rodrigues
90
Community Expert
Product Designer|Entrepreneur |Founder of designwithjohn.com (Project Leader)
 · HonnavarIndia
Share
Report
Get Link

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

Like
0 like 
Award Contribution
Leave a reply...
DISCOVER
CHAT
HIRE
ACTIVITY
FEED
New Post
Help
Start Project
Online Users
Share Link