KRIVANJADIYables
Published © GPL3+

Working with a Potentiometer and Two LEDs

This project demonstrates the use of a potentiometer to control two LEDs.

BeginnerProtip12,911
Working with a Potentiometer and Two LEDs

Things used in this project

Story

Read more

Schematics

Circuit Diagram

Schematic Diagram

Breadboard Diagram

Code

Code

Arduino
const int analog_ip = A0;
const int LED1 = 3;
const int LED2 = 9;
int inputVal = 0;

void setup() {
  pinMode (LED1, OUTPUT);
  pinMode (LED2, OUTPUT);
}

void loop() {
  inputVal = analogRead(analog_ip);
  analogWrite (LED1, inputVal/4);
  analogWrite (LED2, (1023-inputVal)/4);
  
}

Credits

KRIVANJA

KRIVANJA

37 projects • 52 followers
www.krivanja.dev
DIYables

DIYables

0 projects • 76 followers
I would like to invite you to join and add your projects to DIYables platform https://www.hackster.io/diyables

Comments