Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Arduino BLINK Blueprints

You're reading from   Arduino BLINK Blueprints Get the most out of your Arduino to develop exciting and creative LED-based projects

Arrow left icon
Product type Paperback
Published in May 2016
Publisher Packt
ISBN-13 9781785284182
Length 134 pages
Edition 1st Edition
Tools
Arrow right icon
Authors (2):
Arrow left icon
Utsav Shah Utsav Shah
Author Profile Icon Utsav Shah
Utsav Shah
Samarth Shah Samarth Shah
Author Profile Icon Samarth Shah
Samarth Shah
Arrow right icon
View More author details
Toc

Programming an LED array

An LED array is nothing but a few LEDs connected together. Usually, an LED array comes in sizes of eight LEDs and 16 LEDs. You can control an LED array directly using the digitalWrite() function. Apart from using the digitalWrite() function, you can control LEDs directly using port-level communication. On Arduino, we have three ports: ports B, C, and D:

  • Port B: Digital pins 8 to 13
  • Port C: Analog pins
  • Port D: Digital pins 0 to 7

Each port is controlled by three DDR registers. These registers are defined variables in Arduino as DDRB, DDRC, and DDRD. Using these variables, we can make the pins either as input or output in the setup function.

You can use the following syntax to initialize the pins:

DDRy = Bxxxxxxxx

Here, y is the name of the port (B/C/D) and x is the value of the pin that determines if the pin is input or output. We will use 0 for input and 1 for output. LSB (least significant byte) is the lowest pin number for that register.

To control pins using this port...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime