Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

4. What will the following Arduino code do? Please explain in a few words. (4 points) You may want to revisit the Arduino coding assignment

image text in transcribed

4. What will the following Arduino code do? Please explain in a few words. (4 points) You may want to revisit the Arduino coding assignment from previous week for this question. In this setup, a motor is connected to an H-bridge, which is controlled by pin11 and pin 10. A distance sensor is connected to pin 2. Here is the code: int motorPin1-11; Variables defined before setup and loop functions can be used anywhere in any function. int motorPin2= 10; int distance_sensor_pin 2; long int pulse_duration, distance_in_inches; //l The setup function void setup0 pinMode(motorPin1, OUTPUT); pinMode(motorPin2, OUTPUT); Serial.begin(9600); ) // end of setup function // The loop function void loop0 // read the distance pinMode( distance_sensor_pin, OUTPUT); digitalWrite( distance_sensor_pin, LOW; delayMicroseconds(2); digitalWrite( distance_sensor_pin, HIGH); delayMicroseconds(5); digitalWrite( distance_sensor_pin, LOW; pinMode( distance_sensor_pin, INPUT); pulse_duration-pulseln( distance_sensor_pin, HIGH); distance_in_inches pulse_duration /74/2; Serial.println(distance_in_inches); delay(200); // do stuff if (distance_in_inches> 10) ( digitalWrite(motorPin1, HIGH); digitalWrite(motorPin2, LOW) else if (distance_in_inches

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Transactions On Large Scale Data And Knowledge Centered Systems Xxviii Special Issue On Database And Expert Systems Applications Lncs 9940

Authors: Abdelkader Hameurlain ,Josef Kung ,Roland Wagner ,Qimin Chen

1st Edition

3662534541, 978-3662534540

More Books

Students also viewed these Databases questions