Back to Parent

int ledPin = D2;
int buttonPin = D3;
int buttonState;

int potPin = A5;
int potReading = 0;

void setup() {
    pinMode( buttonPin, INPUT_PULLUP);
    pinMode( ledPin, OUTPUT);
}

void loop() {
   potReading = analogRead( potPin );
   int brightness = map( potReading, 0, 4095, 0, 255 );
   analogWrite( ledPin, brightness );
   
   
    // int buttonReading = digitalRead( buttonPin);
    //  int buttonState = digitalRead( buttonPin );
    // if( buttonState == LOW) {
    //     digitalWrite( ledPin, HIGH);
    // }else{
    //     digitalWrite( ledPin, LOW);
    // }
    
    delay( 500 );
   

}
Click to Expand

Content Rating

Is this a good/useful/informative piece of content to include in the project? Have your say!

0