LOGIN
John Rodrigues
88
Community Expert
Mechanical Design Engineer |Founder of designwithjohn.com (Project Leader)
 · HonnavarIndia
Share
Report
Get Link
TASK
Open
Reward › Contribution Review

Task is to come up with a circuit for the following code

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);
}


Task is to come up with the circuit for the above code
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;


}
Contributions
Awais Khawar

Awais has given us the code
Thanks alot Awais
He has been very Helpful
Keep up the Good Job

2 likes 
Like
Award Contribution
Load 2 previous comments
Steven Reubenstone
39
Community Expert
Mechanical Engineer & Tinkerer of Things.
 · New YorkU.S.
Share
Report
Get Link

yes just click edit from the drop down

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

Thanks for Positive Response

Like
2 likes 
Award Contribution
Steven Reubenstone
39
Community Expert
Mechanical Engineer & Tinkerer of Things.
 · New YorkU.S.
Share
Report
Get Link

Excellent work here guys, I love this robot. I want to continue to make it more powerful

Like
0 like 
Award Contribution
Steven Reubenstone
39
Community Expert
Mechanical Engineer & Tinkerer of Things.
 · New YorkU.S.
Share
Report
Get Link

I have added Awais as official mentor of this project

Like
0 like 
Award Contribution
Talha Hashmi
2
Apprentice
Student of Avionics Engineering
 · IslamabadPakistan
Share
Report
Get Link

Is this motor code is of controlling robot or suctioning(Vaccum) ?

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

motor code with distance censer

Like
0 like 
Award Contribution
JOIN TASK
LEAVE A REPLY
DISCOVER
CHAT
HIRE
ACTIVITY
FEED
New Post
Help
Start Project
Online Users
Share Link