Skip to Content
Learning FPGAs
book

Learning FPGAs

by Justin Rajewski
August 2017
Beginner
230 pages
5h 39m
English
O'Reilly Media, Inc.
Content preview from Learning FPGAs

Chapter 7. Mixing Colors with an RGB LED

In this chapter, we will hook up a red, green, and blue (RGB) LED to the Mojo and use pulse-width modulation (PWM), to fade the colors in and out. We will then explore how to use the Register Interface to control the LED. The Register Interface provides a simple way to interface your designs with your computer without having to parse streams of characters in the FPGA. We will be using this to allow you to set the color of the LED from your computer.

To complete these examples, you need an RGB LED and three resistors with a value close to 330 ohms. The LED I’m using is a common anode type (LEDs share a single positive pin, and the negative sides are used to control them individually), but a common cathode LED will work as well. You may also want a breadboard and some jumper wires.

We are going to use the pins 40, 50, and 51 on the Mojo. They are located in the top-left corner and are colored red in Figure 7-1.

Mojo Pins
Figure 7-1. Mojo pinout with pins 40, 50, and 51 highlighted in red

Take your LED and connect the three LED color channels to the three pins. It doesn’t matter which pins you choose, as you’ll see later, but I used 40 for red, 51 for green, and 50 for blue. All that is important is that you know which is which. Make sure that you connect the LED with the resistors between it and the Mojo. If you have a common anode LED, connect the ...

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.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Getting Started with FPGAs

Getting Started with FPGAs

David Romano
Learning Algorithms

Learning Algorithms

George Heineman

Publisher Resources

ISBN: 9781491965481Errata Page