Skip to Content
Arduino Cookbook, 3rd Edition
book

Arduino Cookbook, 3rd Edition

by Michael Margolis, Brian Jepson, Nicholas Robert Weldin
April 2020
Intermediate to advanced
795 pages
17h 43m
English
O'Reilly Media, Inc.
Book available
Content preview from Arduino Cookbook, 3rd Edition

Visual Output

7.0 Introduction

Visual output lets the Arduino convey information to users, and toward that end, the Arduino supports a broad range of LED devices. (Arduino can also display information with graphical display panels, which is covered in Chapter 11.) Before delving into the recipes in this chapter, we’ll discuss Arduino digital and analog output and explain how Arduino works with light-emitting diodes (LEDs). This introduction will be a good starting point if you are not yet familiar with using digital and analog outputs (digitalWrite and analogWrite) or with using LEDs in a circuit. The recipes in this chapter cover everything from simple single-LED displays to creating the illusion of motion (Recipe 7.7) and showing shapes (Recipe 7.9).

Digital Output

All the pins that can be used for digital input can also be used for digital output. Chapter 5 provided an overview of the Arduino pin layout; you may want to look through the introduction section in that chapter if you are unfamiliar with connecting things to Arduino pins.

Digital output causes the voltage on a pin to be either high (5 or 3.3 volts depending on board) or low (0 volts). Use the digitalWrite(outputPin, value) function to turn something on or off. The function has two parameters: outputPin is the pin to control, and value is either HIGH (5 or 3.3 volts) or LOW (0 volts).

For the pin voltage to respond to this command, the pin must have been set in output mode using the pinMode(outputPin, OUTPUT)

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Arduino for Arduinians

Arduino for Arduinians

John Boxall
Getting Started With Arduino, 4th Edition

Getting Started With Arduino, 4th Edition

Massimo Banzi, Michael Shiloh

Publisher Resources

ISBN: 9781491903513Errata PageSupplemental Content