10 Segment LED Bar Graph - Red wiki-DFRobot

FIT0188 10 Segment LED Bar Graph - Red

Introduction

These 10 segment bar graph LEDs have many uses. With a compact footprint, and a simple hookup, they are easy for prototyping or finished products. Essentially, they are 10 individual red LEDs housed together.

Applications

Specification

Shipping List

Connection Diagram

FIT0188 10 Segment LED Bar Graph - Red Connection Diagram

Please note that the connection diagram shows the pins connected in reverse order for the sake of clarity. When you run the sample code included here you might notice a reverse order sequence. If you wish to wire the LEDs in the correct order you should wire: Arduino D2 to PIN1 Arduino D3 to PIN2 Arduino D4 to PIN3 Arduino D5 to PIN4 and so on...

Alternatively you could modify the sample code to operate in the expected order.

Sample Code

// #
// # Editor     : Lauren from DFRobot
// # Date       : 19.03.2012

// # Product name: 10 Segment LED Bar Graph
// # Product SKU : FIT0188
// # Version     : 1.0

// # Description:
// # The sketch for using the 10 Segment LED Bar Graph with prototype shield

// # Connection:
// #        LED Bar positive pins -- Arduino digital pins through a 1K resistor
// #        LED Bar negative pins -- GND

const int ledPin[10] =  {
  2,3,4,5,6,9,10,11,12,13};      // the number of the LED pins
int ledState = 0;

void setup() {
  Serial.begin(9600);
  // set the digital pin as output:
  for(int i = 0; i < 10 ;i   ){
    pinMode(ledPin[i], OUTPUT);
    digitalWrite(ledPin[i], LOW);
  }
  ledState = 1;
  display(ledState);
  delay(100);
}

void loop()
{
  for(int i = 0; i < 9; i  ){
    ledState = ledState << 1;
    display(ledState);
    delay(50);
    Serial.println(ledState,BIN);
  }
  for(int i = 9; i > 0; i--){
    ledState = ledState >> 1;
    display(ledState);
    delay(50);
    Serial.println(ledState,BIN);
  }
}

void display(int sat){
  for(int i = 0; i < 10 ;i   ){
    digitalWrite(ledPin[i],bitRead(ledState,i));
  }
}

More Documents

DFshopping_car1.png Get 10 Segment LED Bar Graph from DFRobot Store or DFRobot Distributor.

Category: DFRobot > Sensors & Modules > LCDs, LEDs & Displays > LEDs category: Product Manual category: FIT Series category: Components category: Source category: Diagram

Turn to the Top