Hi guys,
I have a problem with changing the brightness of my LED connected through Arduino Nano. I have a pot connected to an analog input and I mapped it from 0 to 255. I then applied this value in the digitalWrite func. When I check the values through serial monitor everything is ok, but the led is just on or off. The brightness doesn't change. Im using B100K pot and 220 ohm res with yellow LED. I have tried different pots and LEDs but nothing changes. I even set the brightness manually in the code outstepping the pot but nothing changed. Here is the code:
int led = 2;
void setup() {
Serial.begin(9600);
pinMode(led, OUTPUT);
pinMode(A0, INPUT);
}
void loop() {
int potval = analogRead(A0);
int power = map(potval, 0, 1023, 0, 255);
digitalWrite(led, power);
Serial.println(power);
}
I really don't know what is going on. Thanks for help

