[Project 18] – 14 LED’s Control Using Potentiometer with The Arduino

In this project we will control 14 LED's using potentiometer with the Arduino.  I will use arduino uno in the circuit design program. I use usually arduino mega 2560. You can use the other arduino cards. Good Luck.

Circuit:


[Project 18] - 14 LED's Control Using Potentiometer with The Arduino 324

Materials:


Arduino Mega/Uno  x1
Breadboard  x1
LED  x14
110 ohm Resistor  x14
Potentiometer(10Kohm)  x1
Jumper Cable
 

Program:

//  letsarduino.com
//  [Project 18]  
//  14 LED's Control Using Potentiometer with The Arduino
int led_1 = 13;
int led_2 = 12;
int led_3 = 11;
int led_4 = 10;
int led_5 = 9;
int led_6 = 8;
int led_7 = 7;
int led_8 = 6;
int led_9 = 5;
int led_10 = 4;
int led_11 = 3;
int led_12 = 2;
int led_13 = 1;
int led_14 = 0;
int pot_pin = A0;
const int pot = 0;
int pot_value = 0;

void setup(){

pinMode(led_1,OUTPUT);
pinMode(led_2,OUTPUT);
pinMode(led_3,OUTPUT);
pinMode(led_4,OUTPUT);
pinMode(led_5,OUTPUT);
pinMode(led_6,OUTPUT);
pinMode(led_7,OUTPUT);
pinMode(led_8,OUTPUT);
pinMode(led_9,OUTPUT);
pinMode(led_10,OUTPUT);
pinMode(led_11,OUTPUT);
pinMode(led_12,OUTPUT);
pinMode(led_13,OUTPUT);
pinMode(led_14,OUTPUT);
pinMode(pot_pin,INPUT);
}

void loop(){
      pot_value = analogRead(pot_pin);
      if(pot_value>=0 && pot_value<74)
      { 
      digitalWrite(led_1,HIGH);
      }
      else{
      digitalWrite(led_1,LOW);
      }
       pot_value = analogRead(pot_pin);
      if(pot_value>=74 && pot_value<148)
      { 
      digitalWrite(led_2,HIGH);
      }
      else{
      digitalWrite(led_2,LOW);
      }
      pot_value = analogRead(pot_pin);
      if(pot_value>=148 && pot_value<222)
      { 
      digitalWrite(led_3,HIGH);
      }
      else{
      digitalWrite(led_3,LOW);
      }
      pot_value = analogRead(pot_pin);
      if(pot_value>=222 && pot_value<296)
      { 
      digitalWrite(led_4,HIGH);
      }
      else{
      digitalWrite(led_4,LOW);
      }
      pot_value = analogRead(pot_pin);
      if(pot_value>=296 && pot_value<370)
      { 
      digitalWrite(led_5,HIGH);
      }
      else{
      digitalWrite(led_5,LOW);
      }
      pot_value = analogRead(pot_pin);
      if(pot_value>=370 && pot_value<444)
      { 
      digitalWrite(led_6,HIGH);
      }
      else{
      digitalWrite(led_6,LOW);
      }
      pot_value = analogRead(pot_pin);
      if(pot_value>=444 && pot_value<518)
      { 
      digitalWrite(led_7,HIGH);
      }
      else{
      digitalWrite(led_7,LOW);
      }
      pot_value = analogRead(pot_pin);
      if(pot_value>=518 && pot_value<592)
      { 
      digitalWrite(led_8,HIGH);
      }
      else{
      digitalWrite(led_8,LOW);
      }
      pot_value = analogRead(pot_pin);
      if(pot_value>=592 && pot_value<666)
      { 
      digitalWrite(led_9,HIGH);
      }
      else{
      digitalWrite(led_9,LOW);
      }
      pot_value = analogRead(pot_pin);
      if(pot_value>=666 && pot_value<740)
      { 
      digitalWrite(led_10,HIGH);
      }
      else{
      digitalWrite(led_10,LOW);
      }
      pot_value = analogRead(pot_pin);
      if(pot_value>=740 && pot_value<814)
      { 
      digitalWrite(led_11,HIGH);
      }
      else{
      digitalWrite(led_11,LOW);
      }
      pot_value = analogRead(pot_pin);
      if(pot_value>=814 && pot_value<888)
      { 
      digitalWrite(led_12,HIGH);
      }
      else{
      digitalWrite(led_12,LOW);
      }
      pot_value = analogRead(pot_pin);
      if(pot_value>=888 && pot_value<972)
      { 
      digitalWrite(led_13,HIGH);
      }
      else{
      digitalWrite(led_13,LOW);
      }
      pot_value = analogRead(pot_pin);
      if(pot_value>=972 && pot_value<1024)
      { 
      digitalWrite(led_14,HIGH);
      }
      else{
      digitalWrite(led_14,LOW);
      }
      
      }

 

Project Related Images:


[Project 18] - 14 LED's Control Using Potentiometer with The Arduino 76[Project 18] - 14 LED's Control Using Potentiometer with The Arduino 34[Project 18] - 14 LED's Control Using Potentiometer with The Arduino 534









You may also like...