Sensing with the Potentiometer (Arduino)

Albert Hodo
2 min readSep 22, 2022

Albert Hodo. Tangible User Interface, Fall 2022.

Prompt:You need 3 pots. Use each potentiometer to control the brightness of one LED, so the brightness of each LED can be individually controlled. So one potentiometer controls the red LED, one potentiometer controls the blue LED, and one potentiometer controls the green LED

Components Used

  1. Arduino Uno
  2. Bread Board
  3. 3 Potentiometers
  4. 3 LEDs
  5. 3 Resisters
  6. Jumpwires

Process: Using Pulse Width Modulation with the LEDs, I was able to take the analog input of the potentiometers and conect each of them to the value of an LED. This allowed me to complete the task and the code below shows the process.

Code

/*
Blink with potentiometer
each potentiometer changes
the brightness of each led
*/
const int bluePin = 9; // select the pin for the LED
const int greenPin = 10;
const int redPin=11;
const float potPin1 = A0;
const float potPin2 = A1;
const float potPin3 = A2;
float blueVal;
float redVal;
float greenVal;
// the setup function runs once when you press reset or power the board
void setup() {

Serial.begin(9600);

pinMode(bluePin, OUTPUT);
pinMode(greenPin, OUTPUT);
pinMode(redPin, OUTPUT);
pinMode(potPin1,INPUT);
pinMode(potPin2,INPUT);
pinMode(potPin3,INPUT);

}
// the loop function runs over and over again forever
void loop() {
//convert sensorval to ledvalue
blueVal=(analogRead(potPin1)*0.00095)*255;
greenVal=(analogRead(potPin2)*0.00095)*255;
redVal=(analogRead(potPin3)*0.00095)*255;
Serial.println(blueVal);
Serial.println(greenVal);
Serial.println(redVal);
Serial.println(": ");
analogWrite(bluePin, blueVal);
analogWrite(greenPin,greenVal);
analogWrite(redPin, redVal);
delay(500);
}

Image

arduino with LEDs controlled by potentiometers

--

--

Albert Hodo

I’m a first year MDes student at UC Berkeley. A master’s jointly run by the College of Engineering and Environmental Design. I love outer space and tangible UI.