Interface Potentiometer and dc motor with Arduino Uno. Develop an Arduino sketch to control speed of DC motor using Potentiometer.

Here i am using online IDE Tinkercad . If you don't know what is tinkercad then refer my blog HERE or else you can use offline IDE also.

Code :-

int c1 = 0;

int c2 = 0;  

void setup()  {

  pinMode(12, OUTPUT);

  pinMode(A0, INPUT); 

}

void loop()

{

  c2= analogRead(A0);

  c1= 1024-c2;        

  digitalWrite(12, HIGH);

  delayMicroseconds(c1);  

  digitalWrite(12, LOW); 

  delayMicroseconds(c2); 

}

Output :-



Comments

Popular Posts

What is Tinkercad ? How to use Tinkercad ?

Connect switch to Arduino. If switch is on than print ”ON” else print “OFF” on serial monitor.

Set the time using four switch and display the clock on LCD using arduino ** SW1 : when press, increment 1 digit ** SW2 : when press, decrement 1 digit ** SW3 : when press, display set time and start the clock ** SW4 : when press, reset the clock