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
09939 01
Rotary potentiometer (generic)
×1
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
Tudose Matei

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!

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

Give feedback

Comments

Similar projects you might like

USBphpTunnel
Easy
  • 42
  • 2

Protip

USBphpTunnel - Android app for MXQ TV box to control an Arduino board via USB from PHP.

Arduino morse code machine
Easy
  • 287
  • 7

Full instructions

A simple arduino Morse code machine with a button,led and a buzzer that takes your input and translates it into English while you are typing

Arduino 101 - Intel Curie Pattern Matching Dress
Easy
  • 1,272
  • 13

Full instructions

A dress with Curie's pattern matching engine on Arduino101 to control the embedded LEDs, which makes constellations show up on the dress.

Arduino Laser Tripwire
Easy
  • 1,592
  • 14

Full instructions

An Arduino Uno project that utilizes a laser to detect when the laser beam has been interrupted.

Chug Meter for St. Patrick's Day by Circuito.io
Easy
  • 1,672
  • 9

Full instructions

Let’s settle once and for all - who is the fastest chugger of ‘em all?

Smart Home Sensor Node
Easy
  • 239
  • 3

Work in progress

Build a sensor node using Arduino/Genuino 101 which integrated with openHAB 2, which you can build a smart home control system in no time.

ProjectsCommunitiesContestsLiveJobsBetaFree StoreBlogAdd projectSign up / Login
Respect project
Feedback