DAT 406 – Arduino: Potentiometer-controlled LED

This is the result of a practical task with Arduino that uses a potentiometer to vary the flashing speed of an LED. The code listed in this article takes the analogue input from the potentiometer. This value is then used to vary the time between the LED being on and being off.

Arduino code:

int sensorPin = 0;
int ledPin = 13;

void setup() {
pinMode(ledPin, OUTPUT);

void loop() {
int sensorValue = analogRead(sensorPin);
digitalWrite(ledPin, HIGH);
digitalWrite(ledPin, LOW);


Leave a Reply

Your email address will not be published. Required fields are marked *


This site uses Akismet to reduce spam. Learn how your comment data is processed.