Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Explain the code line by line?! #include HCSR04,h> #define leftMotorForwardPin 8 #define leftMotorBackwardPin 9 #define rightMotorForwardPin 6 #define rightMotorBackwardPin 7 #define leftMotorSpeedPin 11 #define rightMotorSpcedPin
Explain the code line by line?!
\#include HCSR04,h> \#define leftMotorForwardPin 8 \#define leftMotorBackwardPin 9 \#define rightMotorForwardPin 6 \#define rightMotorBackwardPin 7 \#define leftMotorSpeedPin 11 \#define rightMotorSpcedPin 10 \#define IR Front 4 \#define IR_Back 2 UltraSonicDistanceSensor ultrasonic(A5,A4); float distance; void setup() i pinMode(leftMotorSpeedPin, OUTPUT): pinMode(leftMotorForwardPin, OUTPUT); pinMode(leftMotorBackwardPin, OUTPUT): pinMode(rightMotorSpeedPin, OUTPUT); pinMode(rightMotorForwardPin, OUTPUT); pinMode(rightMotorBackwardPin, OUTPUT); Serial.begin(9600); pinMode(IR_Front, INPUT); pinMode(IR_Back, INPUT): digitalWrite(leftMotorSpeedPin, HIGH); / 0-255 digitalWrite(rightMotorSpeedPin, HIGH); delay(2000); void loop() \{ distance = ultrasonic.measureDistanceCm(), // Lise "CM" for centimeters or "INC" for inches Serial.printlin(distance): int IrF_Result = digitaIRead(IR_Front); int IrB_Result = digitalRead(IR_Back); void stop() digitalWrite(leftMotorForwardPin, LOW); digitalWrite(leftMotorBackwardPin, LOW); digitalWrite(rightMotorForwardPin, LOW); digitalWrite(rightMotorBackwardPin, LOW); \} Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started