Reader small image

You're reading from  Arduino BLINK Blueprints

Product typeBook
Published inMay 2016
PublisherPackt
ISBN-139781785284182
Edition1st Edition
Tools
Right arrow
Author (1)
Utsav Shah
Utsav Shah
author image
Utsav Shah

Utsav Shah is an instrumentation engineer who loves to work on the latest hardware as well as software technologies. He has been featured on India's leading website http://yourstory.in and Ahmedabad Mirror (Times Group) for his research work on "Converting sign language into speech" using a Leap Motion controller. Apart from his regular work at Infosys Limited, he manages activities of Infosys Robotics Club. In his leisure time, he loves to read books and work on cutting-edge technologies.
Read more about Utsav Shah

Right arrow

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 page is locked
Previous PageNext Page
You have been reading a chapter from
Arduino BLINK Blueprints
Published in: May 2016Publisher: PacktISBN-13: 9781785284182

Author (1)

author image
Utsav Shah

Utsav Shah is an instrumentation engineer who loves to work on the latest hardware as well as software technologies. He has been featured on India's leading website http://yourstory.in and Ahmedabad Mirror (Times Group) for his research work on "Converting sign language into speech" using a Leap Motion controller. Apart from his regular work at Infosys Limited, he manages activities of Infosys Robotics Club. In his leisure time, he loves to read books and work on cutting-edge technologies.
Read more about Utsav Shah