Question: I just need the code. H Bridge Motor Control Code #define M _ ENABLE 5 #define M _ DIRECTION 1 0 4 #define M _

I just need the code.
H Bridge Motor Control Code
#define M_ENABLE 5
#define M_DIRECTION104
#define M_DIRECTION013
void setup()
{
pinMode(M_ENABLE, OUTPUT);
pinMode(M_DIRECTION10, OUTPUT);
pinMode(M_DIRECTION01, OUTPUT);
}
void loop()
{
analogWrite(M_ENABLE, 255);
digitalWrite(M_DIRECTION10,1); digitalWrite(M_DIRECTION01,0);
delay(2000);
analogWrite(M_ENABLE, 255);
digitalWrite(M_DIRECTION10,0); digitalWrite(M_DIRECTION01,1);
delay(2000);
analogWrite(M_ENABLE, 126);
digitalWrite(M_DIRECTION10,1); digitalWrite(M_DIRECTION01,0);
delay(2000);
analogWrite(M_ENABLE, 126);
digitalWrite(M_DIRECTION10,0); digitalWrite(M_DIRECTION01,1);
delay(2000);
}
H Bridge Motor Control Circuit
Build the following circuit first on Tinkercad and then with your Arduino kit. Use the starter code on the next slide, which will alternate the motors speed and direction every two seconds.
Connections between H Bridge and Arduino:
H1(Enable) to Arduino 5
H2\((\ln 1)\) to Arduino 4
H7(In2) to Arduino 3
H Bridge Lab
Extend your circuit to include a potentiometer, button and LED and implement the following functionality:
BTN toggle
- LED and Motor both on and off.
PTM dial controls motor speed and direction
- middle position: motor is at rest.
- dial left: motor spins left
- dial right: motor spins right
- moving the dial away from the center position in either way speeds up the motor
- use the \(\operatorname{map}(\)) function to assign the motor speed from 0 to 255 according to the dial position
I just need the code. H Bridge Motor Control Code

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Electrical Engineering Questions!