How to make a robot without using a single library?

Hello, Rezvan here. I am here to instruct you about making a robot without using a single library.

Step 1. Do the wiring, like this:
Ground to Ground,
7 to INA1,
6 to INA2,
8 to PWMA,
4 to INB1,
3 to INB2,
5 to PWM.
Step 2. Enter Arduino IDE.
Step 3. Do the code, like this

const int enA = 8;
const int in1 = 7;
const int in2 = 6;
const int enB = 5;
const int in3 = 4;
const int in4 = 3;
void setup() {
pinMode(enA, OUTPUT);
pinMode(enB, OUTPUT);
pinMode(in1, OUTPUT);
pinMode(in2, OUTPUT);
pinMode(in3, OUTPUT);
pinMode(in4, OUTPUT);
}
void demoOne(){
digitalWrite(in1, HIGH);
digitalWrite(in2, LOW);
analogWrite(enA, 200);
digitalWrite(in3, HIGH);
digitalWrite(in4, LOW);
analogWrite(enB, 200);
delay(1000);
digitalWrite(in1, LOW);
digitalWrite(in2, HIGH);
digitalWrite(in3, LOW);
digitalWrite(in4, HIGH);
delay(1000);
digitalWrite(in1, LOW);
digitalWrite(in2, LOW);
digitalWrite(in3, LOW);
digitalWrite(in4, LOW);

}

void demoTwo(){

digitalWrite(in1, LOW);
digitalWrite(in2, HIGH);
digitalWrite(in3, LOW);
digitalWrite(in4, HIGH);

for (int i = 0; i <200; i++)
{
 analogWrite(enA, i);
 analogWrite(enB, i);
 delay(20);
}

for (int i = 0; i <200; i++)
{
 analogWrite(enA, i);
 analogWrite(enB, i);
 delay(20);
}
digitalWrite(in1, LOW);
digitalWrite(in2, LOW);
digitalWrite(in3, LOW);
digitalWrite(in4, LOW);
}

void loop(){
demoOne();
delay(1000);
demoTwo();
delay(1000);
}

Step 4. Work is done!

For the board, I used an Arduino Mega so that people using an uno or Nano might try to connect 8 expecting PWM.

Do you think this code will able to teach somebody something new and useful? Do you consider it as an example of good programming style?

Are you sharing your homework? (Yes, I am making a lot of assumptions)

I don't know what you mean by an extension. Please explain.

What wiring? If you want to instruct us we need to know what wiring to do. So post a schematic of the wiring because my crystal ball is on the blink and I can't read your mind.

Yeah, the Little Rascals One Move At A Time robot.

Learn more C/C++ and spend weeks if need be learning How To Do Many Things At Once with Arduino. It will put you on a whole new level of coding.

This is the best start that I know of.

It teaches how to blink 2 leds at different rates at the same time without using delay(). The DIRTY thing about delay is that it totally wastes 16000 CPU cycles per ms delayed where a well written loop() can average around 300 cycles of DOING NOT WASTING. When we do tasks that don't wait around, Arduino gets very fast and multiple things get done together smoothly, and the code can be written in small pieces instead one grand complex knot.

To me a simple 2 things at once task is a button and led where push the button to toggle led blinking ON/OFF. It takes time to blink where it also has to watch the button pin.. 2 things at once simple.

Nice code. Identify motor direction for wiring. I see you have "skid steering" for a bit of time. I would like to share my "steering" simulation that includes forward, reverse, turn, rotate, skid steer, and PWM!

Work is never done.
What about blinking lights, buzzers, blurtooth control, distance sensing...

I forgot.

An extension (or library) is something that you add to your projects.

It's now done!

Congratulations.
Now you can turn your code into a library.

Please mention board type, project details, and any other information or metadata as well.

After reading the OP, I only understand:
"This is baremetal level of coding. Which means it will be efficient."

What I don't understand:
"Which board to use?"
"Which motors?"
etc.

If you feel you don't know the answer, it is very easy to figure out. Go through other posts and see how it is done by the pros or older players.

Best to try out with a project you want to replicate, so that you can face the problems first hand and ask those questions.

Keep a mental note (or write it on pad if it helps, no shame) on:
What information have you received from that post?
Are you fulfilled after reading the post?
If not, what would be the points that you can add to improve on it?
Are the changes you adding an innovative fork, a good addition of any feature which was absent, or a mindless copy?

Answering these questions will help you figure out what you want, which is what people wants. Calibrating your sense with the average sense of the world is the exercise that you have to go through to write a well received useful helping article.

Nowadays there are AI and LLMs to help you out, but they come with caveats. It is a great power that you have to use responsibly, else damage other people and get publicly humiliated:

NEVER TAKE LLM ANSWERS FOR GRANTED. Do your due diligence. Check with other LLMs. Check for plagiarism.
THERE IS NO ESCAPE FROM LEARNING CODE SYNTAX. So you better start the basics now if you haven't already, and thank me later when you become confident enough, that you start correcting LLM errors.
ALWAYS TEST YOUR CODE BEFORE RELEASING TO PUBLIC. This is more like an ethical diligence. You are contributing in the open source community Without standards, there is no point for even having anything open source. Tell public ONLY WHAT YOU ARE SURE OF, and not what an LLM or an AI is telling you.
Be the master over the LLM instead of THE AI USING YOU AS AN OPERATING SYSTEM FOR THE WORLD. (It is even more sadder if you are paying for the service, because technically you should be the one getting paid for training the AI).

Cheers
Ninaad

It is far from that. For instance, digitalWrite() is slower than using direct register access, to say nothing of the possibility of using assembler

My driver board only has the following pins:

GND
Vin
PWM
DIR
EN*

How do I use your program to control my motor.

For the board, I used an Arduino Mega.

Add this note to post #1... (or the title?) someone using Uno or Nano might try to connect "8" expecting PWM.

Why the question mark at your post topic?

What are you asking?

I am just instructing.

Oh, most people call them a library. Glad you changed the title.

Maybe you could consider moving the thread to Products -> Showcase so more people could read it, and it would last a lot longer and be more helpful in future.

What is the Arduino wiring if not an extension above a GCC C++ language?

If you claim that you don't use extensions, why are there pinMode() and digitalWrite() in the code?