Question: 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

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
Get step-by-step solutions from verified subject matter experts
