Tuesday, 8 December 2015

Arduino Challenge 4: Potentiometer (Make Your Own Challenge)

Challenge Name: Poteniometer & LED Brightness

Author: Christina He

Credit: New Innovators.ca Lab 4

Difficulty Level: Level 2

Time to Complete: Approximately 30 min

Challenge Description: Make one LED to blink with different levels of brightness by twisting the potentiometer.

Answer:

Code

int ledPin = 13;
int value = 0;
void setup()
{
  pinMode (ledPin , OUTPUT);
  pinMode(sensorPin, INPUT);
}
void loop()
{
  value = analogRead(sensorPin);
  analogWrite(ledPin , value);
  delay(100);

}

Visual Answer




No comments:

Post a Comment