PWM Controlled DC Motor | What is MAP in arduino?





code:-



const int PWM = 3;

const int analogPin = 0;



void setup()

{

 

Serial.begin(9600);

}



void loop()

{

 int adc = analogRead(analogPin); 

 int val = map(adc, 0, 1023, 0, 255);

 Serial.println(val);

  analogWrite(PWM, val);

}

Comments