LED wiring
Tuesday, 29 September 2009
The Arduino Mega has 54 digital I/O pins, 50 of which are each driving an LED on the Hi-Striker. Each pin can drive up to 40mA, so the only additional components needed are one 100k current-limiting resistor per LED.
For testing, a simple cascading loop runs through the (first 16) LEDs one at a time:
const int ledCount = 16; // the number of LEDs in the bar graph int ledPins[] = { 2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17 }; // 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() { // loop over the LED array: for (int thisLed = 0; thisLed < ledCount; thisLed++) { digitalWrite(ledPins[thisLed], HIGH); // turn on the LED delay(20); // wait digitalWrite(ledPins[thisLed], LOW); // turn off the LED } }




No. 1 — November 9th, 2009 at 12:55 am
Thanks alot for the great read.
No. 2 — November 27th, 2009 at 8:01 am
I wrote a similar blog regarding this subject but your is better.