Saturday, April 23, 2016

10-Segment LED kit Landing Page

Short Description
This nifty bar graph module is a convenient 20-pin DIP (dual inline plastic) packages consisting of 10 separate LED. Are you one of their latest bright four modules, each color (red, yellow, green, blue) and one, and get enough resistors.


10-Segment LED kit Landing Page
10-Segment LED kit Landing Page
Necessity
Along with the kit is available in this manual should be the following:
  • breadboard
  • Jumper cables
  • Arduino microcontroller or similar
How it works
Each module has 10 independent LED. The pins are arranged so that the anode (positive) pins are on one side of the module, and the cathode (negative) pins directly opposite. Since the package 0.3 "wide, just standard DIP, IC, like a breadboard with their feet straddling the center of the gap is easy to set up. Pin 1 is indicated by the package that corner a little bevel. (Tip: A thin plastic module to a more may peel off crisp appearance) at the top of the film can be saved.

As usual LEDs, LED bar graph 10 to limit the current flowing through the resistor in a series. Fifty Kit 330 ohm resistor, the LED kit comes with all of the light is sufficient.

10-Segment LED kit Landing Page
Pin layout and the typical connections (are shown only the first LED)

How to use it

Hardware
An Arduino, a microcontroller, or any other cable, bar graph, is pretty straightforward. A breadboard- J) each Arduino output (0-9) connections. And with a 330 ohm resistor to ground cathode connection pins. Do not forget to stop at any one of the LED. Otherwise, you may reduce the life of one or more LEDs, and a bar graph that no one wants a segment is missing.

10-Segment LED kit Landing Page
10-Segment LED kit Landing Page
Firmware
Arduino code below shows a few ways to drive straight to the bar graph. Everything hook-up, sketch, upload, and see what happens. (Nothing happens, then make sure that the correct orientation is a bar graph module, and a ground pin on the Arduino to the ground is not connected). This is when you need to drive with your own code, you can reuse this function.



// LED bargraph demo code


// ...in which we provide a few functions to drive a 10-segment LED bargraph


// Mike Grusin, SparkFun Electronics


// This code is completely free to use for your purposes




// Hardware setup

// connect Arduino digital pins 0-9 to LED bargraph pins 1-10


// connect LED pins 11-20 via 330-Ohm resistors to ground




void setup()

  int pin;

{


  

  // set pins 0 to 9 as outputs


  for (pin = 0; pin <= 9; pin++)

  {

    pinMode(pin,OUTPUT);


  }

}



void loop()

  int number;

{


  

// exercise lightOne() up and down


  for (number = 1; number <= 10; number++)

  {
    lightOne(number);

    delay(250);

  }
  

  for (number = 10; number >= 1; number--)

  {
    lightOne(number);

    delay(250);

  }



// exercise barGraph() up and down

  for (number = 1; number <= 10; number++)



  {

    barGraph(number);


    delay(250);

  }
  

  for (number = 10; number >= 1; number--)

  {
    barGraph(number);

    delay(250);

  }



// exercise binary() up and down

  for (number = 0; number <= 1023; number++)



  {

    binary(number);


    delay(10);

  }

  for (number = 1023; number >= 0; number--)

  


  {

    binary(number);


    delay(10);

  }
}

void lightOne(int number)

// input is a number from 0 to 10

// lights only that LED on the bargraph


// (0 lights no LEDs)


{


  int pin;


  for (pin = 0; pin <= 9; pin++)

  {

    if (number-1 == pin)

    {

      digitalWrite(pin,HIGH);


    }


    else


    {


      digitalWrite(pin,LOW);


    }

  }
}

void barGraph(int number)

// input is a number from 0 to 10

// lights that LED and below on the bargraph


// (0 lights no LEDs)


{


  int pin;


  for (pin = 0; pin <= 9; pin++)

  {

    if (number-1 >= pin)

    {

      digitalWrite(pin,HIGH);


    }


    else


    {


      digitalWrite(pin,LOW);


    }

  }
}

void binary(int number)

// input is a number from 0 to 1023 (10 bits)

// if a bit is '1' in that number, the corresponding LED is lit, otherwise it is off


{


  int pin;


  for (pin = 0; pin <= 9; pin++)

  {

    if (number & (1 << pin)) // check if bit position 'pin' in 'number' is a 1 or not


    {


      digitalWrite(pin,HIGH); // it's a 1!


    }


    else


    {


      digitalWrite(pin,LOW); // it's a 0!


    }

  }

}


One thing you'll notice when driving the display that you can quickly run out of pins, each pin is dedicated to a single LED. To drive more leads with fewer pins, shift registers, which Arduino to control additional external synchronous serial interface Take a look at the output pin.

Resources

  • Datasheet (blue LED)
  • Datasheet (green LCD)
  • Datasheet (red LED)
  • Datasheet (yellow LED)
  • YouTube video demo

Conclusion
If you have any questions or suggestions, do not hesitate to contact us at Tech support@sparkfun.com. Have fun with your new display!

No comments:

Post a Comment