Question

An analog distance sensors is to be connected to an Arduino Uno R3. The sensor requires...

An analog distance sensors is to be connected to an Arduino Uno R3. The sensor requires 5V and GND to operate and gives a single analog output (Dout) in the range 0à5V. The voltage is related to (not as cousins) the distance according to the equation: Distance (in cm) = 11 x V + 4. Write a C function to keep the robot away from objects by at least 8 cm. Use the function setMotors(LeftMspeed, RightMspeed) to set the speed of left and right motors. The speed a number between -100 to 100. When both motor speeds are positive (robot moves forward) and when both motor speeds are negative (robot moves backward). Assume sensor is positioned such that it detects objects in front of the robot.

Homework Answers

Answer #1

I am providing the general algorithm to achive the above task .

It says that

Analog Sensor is connected

Sensor requires 5V and GND

Output of sensor (Dout) 0-5V

(Distance)D=11*V+4

function C(To keep robot 8cm away from object)

setMotors(LeftMspeed,RightMspeed)

-100 to 100

Step 1:

C(int D)

{

D=11*V+4 //V is output of sensor

if(D<=8)

{

setMotors(-100,-100); //To move the Bot in backward direction

delay(2 ms);

setMotors(50,0); //To make the robot rotate in reverse direction

delay(1 ms);

setMotors(50,50) ; //Continue moving bot in forward direction

}

else

setMotors(50,50);

}

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT
Active Questions
  • Doctor’s Order: Vancomycin 500mg tab i po q12h X 7 days Available: Vancomycin 500mg tablets What...
    asked 4 minutes ago
  • Calculate the ΔG∘rxn for the reaction using the following information. 4HNO3(g)+5N2H4(l)→7N2(g)+12H2O(l) ΔG∘f(HNO3(g)) = -73.5 kJ/mol; ΔG∘f(N2H4(l))...
    asked 5 minutes ago
  • Question 03: Saturn Shoes (Pvt.) Ltd manufacture multi-style fashion boots for the residents of Missouri. Leather...
    asked 7 minutes ago
  • A highway with a design speed of 100 km/hr is designed with a sag curve connecting...
    asked 19 minutes ago
  • Shift Registers can be used for serial/parallel interface applications. True or false?
    asked 45 minutes ago
  • Scenario 1: To describe the instructors’ experience, the researcher records the year in which each instructor...
    asked 49 minutes ago
  • develop a flowchart or pseudocode to check the prime numbers 1- below 100 what to do...
    asked 49 minutes ago
  • Which of the following statements are true? I. The sampling distribution of ¯xx¯ has standard deviation...
    asked 49 minutes ago
  • Which of the following methods of reporting cash flows provided by operating activities does the Financial...
    asked 50 minutes ago
  • SITUATION 2: EFFECTIVE STRESS An engineer investigates a granular soil deposit, 4 meters thick, overlaying a...
    asked 1 hour ago
  • Suppose that R is a commutative ring and I is an ideal in R. Please prove...
    asked 1 hour ago
  • Shirley Trembley buys a house for $183,800. She puts 20% down and obtains a simple interest...
    asked 1 hour ago