Things used in this project

Hardware components:
09590 01
LED (generic)
×10
A000066 iso both
Arduino UNO & Genuino UNO
×1
Mfr 25fbf52 221r sml
Resistor 221 ohm
×10
11026 02
Jumper wires (generic)
×13
Software apps and online services:
Ide web
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
Matei Tudose

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

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

Playing Smartphone Games with a Relay Touch Board
Easy
  • 1,417
  • 8

I played smartphone games with a relay touch board.

Red Balloon
Easy
  • 1,004
  • 12

Full instructions

This is a great project you can make with your kids to raise their awareness to air pollution.

Simple Arduino Digital Clock Without RTC
Easy
  • 1,925
  • 9

Work in progress

A simple Arduino Clock without RTC module for beginners. #Arduino project for beginners

Arduino/Genuino 101 BLE Thermometer With TMP102 and Blynk
Easy
  • 952
  • 11

Full instructions

Here is how to make an Arduino/Genuino 101 Bluetooth Low Energy thermometer with TMP102 and Blynk.

Simple Arduino-based Thermometer
Easy
  • 649
  • 5

Cool thermometer using Sugru and circuito.io.

Piezo Tunes
Easy
  • 533
  • 5

In this project, you're going to learn how you can play your own melody with a Piezo speaker, using code generated by Circuito.io

ProjectsCommunitiesContestsLiveJobsFree StoreBlogAdd projectSign up / Login
Respect project