Complete the code to set the motor direction pin as output.
pinMode([1], OUTPUT);We use pinMode to set the motor direction pin as an output pin so we can control it.
Complete the code to turn the motor forward by setting motorPin1 HIGH.
digitalWrite(motorPin1, [1]);Setting motorPin1 to HIGH makes the motor spin forward.
Fix the error in the code to stop the motor by setting both direction pins LOW.
digitalWrite(motorPin1, [1]); digitalWrite(motorPin2, [1]);
Setting both direction pins to LOW stops the motor.
Fill both blanks to reverse the motor direction by setting motorPin1 LOW and motorPin2 HIGH.
digitalWrite(motorPin1, [1]); digitalWrite(motorPin2, [2]);
To reverse the motor, set motorPin1 to LOW and motorPin2 to HIGH.
Fill all three blanks to create a 2D array that maps motor states to pin values: forward (motorPin1 HIGH, motorPin2 LOW), reverse (motorPin1 LOW, motorPin2 HIGH), stop (both LOW).
int motorStates[3][2] = { [1], // forward [2], // reverse [3] // stop };
This 2D array maps the motor states to their corresponding pin settings. For example, index 0 ("forward") maps to {HIGH, LOW} for motorPin1 and motorPin2.
