Is this code right?

Is this code right?

const int IN1 = 9;
const int IN2 = 8;
const int IN3 = 7;
const int IN4 = 6;
const int ENA = 11;
const int ENB = 10;

void setup() {

pinMode (IN1, OUTPUT);
pinMode (IN2, OUTPUT);
pinMode (IN3, OUTPUT);
pinMode (IN4, OUTPUT);
pinMode (ENA, OUTPUT);
pinMode (ENB, OUTPUT);


void loop() {
//control speed
analogWrite(ENA, 255);
analogWrite(ENB, 255);
//control direction
digitalWrite(IN1, HIGH);
digitalWrite(IN3, HIGH);
digitalWrite(IN4, LOW);


Is this code right?

Does it compile ?
What is it supposed to do ?
What does it actually do ?

Is this code right?

A few things …

When posting code please use the code button </> to make it easier for people to help you.

As you have not said what the code should do it is not possible to say whether it is right.

The correct thing is for you to run the program and then tell us in detail what it actually does and what you want it to do that is different. Then we can focus on the parts you need help with rather than wasting time on things that you can do. The Arduino system is great for learning-by-doing.


It compiles so if you're using it with the right Arduino and all the right other components then it should do something. If that something is what you want it to do then the code is right.


All the code in loop() could be in setup()