How to control LED brightness with potentiometer and Arduino

Поделиться
HTML-код
  • Опубликовано: 10 сен 2024
  • Tutorial : How to use Potentiometer To Control LED Brightness
    Cost : arround 13$ / 10 €
    Codde and stuff below :
    Example links fot stuff:
    Arduino Uno : fr.aliexpress....
    RED LED Electronics 5mm www.amazon.com...
    Potentiometer : www.amazon.com...
    Wire Breadboard : www.amazon.com...
    Bread Board : www.amazon.com...
    Arduino IDE : www.arduino.cc...
    Code :
    int potPin = A0;
    int ledPin = 11;
    int potValue = 0;
    int ledValue = 0;
    void setup() {
    Serial.begin(9600);
    pinMode (potPin , INPUT);
    pinMode (ledPin , OUTPUT);
    }
    void loop() {
    potValue=analogRead(potPin);
    ledValue=map(potValue, 0, 1023, 0, 255);
    analogWrite(ledPin, ledValue);
    Serial.print("Value of the potentiometer = ");
    Serial.println(potValue);
    Serial.print("Value of the led = ");
    Serial.println(ledValue);
    Serial.print ("
    ");
    delay(1000);
    }
    Let me know if you need more information

Комментарии • 2