Things used in this project

Hardware components:
09590 01
LED (generic)
×10
A000066 iso both
Arduino Arduino UNO & Genuino UNO
×1
Mfr 25fbf52 221r sml
Resistor 221 ohm
×10
11026 02
Jumper wires (generic)
×13
09939 01
Rotary potentiometer (generic)
×1
Software apps and online services:
Ide web
Arduino Arduino IDE

Schematics

Bar Graph
Bargraph bb mfhm8kyoal

Code

GraphC/C++
const int analogPin = A0;   // the pin that the potentiometer is attached to
const int ledCount = 10;    // the number of LEDs in the bar graph

int ledPins[] = {
  2, 3, 4, 5, 6, 7, 8, 9, 10, 11
};   // an array of pin numbers to which LEDs are attached


void setup() {
  // loop over the pin array and set them all to output:
  for (int thisLed = 0; thisLed < ledCount; thisLed++) {
    pinMode(ledPins[thisLed], OUTPUT);
  }
}

void loop() {
  // read the potentiometer:
  int sensorReading = analogRead(analogPin);
  // map the result to a range from 0 to the number of LEDs:
  int ledLevel = map(sensorReading, 0, 1023, 0, ledCount);

  // loop over the LED array:
  for (int thisLed = 0; thisLed < ledCount; thisLed++) {
    // if the array element's index is less than ledLevel,
    // turn the pin for this element on:
    if (thisLed < ledLevel) {
      digitalWrite(ledPins[thisLed], HIGH);
    }
    // turn off all pins higher than the ledLevel:
    else {
      digitalWrite(ledPins[thisLed], LOW);
    }
  }
}

Credits

Arduino icon 2 oz4hdh5f0y
Tudose Matei

I'm a beginner and I love Arduino ! I discovered hardware and software at academy "inventeaza.ro" . This academy is brilliant !

Contact

Replications

Did you replicate this project? Share it!

I made one

Love this project? Think it could be improved? Tell us what you think!

Give feedback

Comments

Similar projects you might like

Water Softener
Easy
  • 176
  • 5

Full instructions

Sweeping frequency magnetic hard water conditioner

Simple Obstacle Senor With Arduino
Easy
  • 61
  • 2

Full instructions

I am Gonna show you how to make a Simple obstacle sensing system with cheap parts like IR led and Photo diode.

Know the Temp of Your Home From Anywhere with Arduino Cloud!
Easy
  • 1,027
  • 9

Full instructions

Ever wanted to know the temperature of your home from somewhere? Here's an easy way to do it with Arduino Cloud and the Yun Shield!

Connect Your Thinxtra Xkit Using Sigfox
Easy
  • 117
  • 2

Protip

Learn how to build an IoT application over Sigfox integrated with Ubidots - send temp readings based on motion sensors.

Safe City: A Device to Keep You Safe
Easy
  • 499
  • 5

Full instructions

The device will keep you safe. Just have to click a button and your precise location will be shared.

Scavenger Hunt Clues w/ Telephone Keypad
Easy
  • 877
  • 3

Full instructions

Type the correct code on the phone's keypad to hear the clue through the handset, then decode the message to finish before the other team.

Sign up / LoginProjectsPlatformsTopicsContestsLiveAppsBetaFree StoreBlog