YouTube Video

Things you need

Arduino UNO

Breadboard wires

Breadboard

L298N Motor Driver Module

potentiometer

Time to code

Hello wuss up
okay so at first of all we need a “long int”  because it has more storage to save our integer after that in void setup we make pin 3 as output for the motor

next in void loop first we read the ADC of pin A0
to control the speed of the motor we need a number between 0 – 255 for that we do a bit of math  as the ADC gives us a number between 0 – 1023

then we just change the PWM duty cycle with analog Write

 

building time

What’s ADC

An Analog to Digital Converter (ADC) is a very useful feature that converts an analog voltage on a pin to a digital number (most of the time 5V = 1023) .

What’s PWM?

Simply it just turns the pin on and off very fast, and we can change the duration of it being on or off

More info:
Pulse Width Modulation, or PWM, is a technique for getting analog results with digital means. Digital control is used to create a square wave, a signal switched between on and off. This on-off pattern can simulate voltages in between the full Vcc of the board (e.g., 5 V on Uno, 3.3 V on a MKR board) and off (0 Volts) by changing the portion of the time the signal spends on versus the time that the signal spends off. The duration of “on time” is called the pulse width. To get varying analog values, you change, or modulate, that pulse width. If you repeat this on-off pattern fast enough with an LED for example, the result is as if the signal is a steady voltage between 0 and Vcc controlling the brightness of the LED.

Thank you for reading/watching, please like and comment down below
0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments