Arduino Map

About: bachelors degree in Electrical Engineering, love developing hardware systems on both microcontrollers and PLC.

-Arduino board
-LED
-Potentiometer

Simply connect the longer leg of your LED to pin 5 of your Arduino and the short leg to GND, connect the potentiometer to GND and +5V and the ADJ to any analog pin on your Arduino board.

Step 1: Code

int led=5;

const int hold=10;

void setup() {

Serial.begin(9600);

// put your setup code here, to run once:

}

void loop()

{

int value=analogRead(A5);

value=map(value,0,1023,0,255);

if(A5 > hold)

{

analogWrite(led, value);

Serial.println(value);

delay(10);

}

// put your main code here, to run repeatedly:

}

Step 2:

Thanks for your time. If you have any questions please leave them as comments.

Share

    Recommendations

    • Toys Contest

      Toys Contest
    • First Time Author

      First Time Author
    • Big and Small Contest

      Big and Small Contest

    Discussions

    0
    None
    mebvf

    2 months ago on Step 2

    What is map function can you tell me? Please.