Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. Finished Starting to play with Arduino
  2. Optional Dimming LED
  3. Basic circuit knowledge

Objectives:

...

  1. Please refer to : http://www.arduino.cc/en/Tutorial/Potentiometer 

    iFramesrchttp://www.arduino.cc/en/Tutorial/Potentiometer

    width960idpotentiometerheight600

     

      Image Added

  2. The original programme will only blink the led using the input as speed of blinking, It's also possible to adjust the LED intensity using the input.

    Code Block
    int potPin = 0;    // select the input pin for the potentiometer
    int ledPin = 9;   // select the pin for the LED (need to be any pin you connected and need to have a "~")
    int val = 0;       // variable to store the value coming from the sensor
    
    void setup() {
      pinMode(ledPin, OUTPUT);  // declare the ledPin as an OUTPUT
    }
    
    void loop() {
      val = analogRead(potPin);    // read the value from the sensor
      analogWrite(ledPin, val >> 2); // because the read value is 0 -> 1023, the output range is 0 -> 255, 
                                     // >> 2 basically is a faster way of dividing by 4
    }