Category Archives: Technology

How Hex Color Codes Work

Where does one person’s interpretation of a color end and another person’s begin? How do we universally define colors displayed on modern screens? What is the equivalent of Pantone for digital documents? In this video, we’ll explore how color is displayed on modern LCD/LED screens before going into depth on how hexadecimal color codes work as a technological standard to convey color information.

Get the Arduino code, bill of materials, and more on element14.com/presents

Check out the rest of Project ColorTyme here

This video is part of a project for the element14 community. The electronics and engineering community where you can connect and collaborate with top engineers from around the world. Join now at element14 dot com, link in the doobly-doo!

Firebrick5 [#8E2323]

Picasso Blue [#0276FD]

Viridianlight [#6EFF70]

These are all very specific colors defined by very specific wavelengths of light, or–more accurately–by very specific ratios of three different specific wavelengths of light: red, blue, and green.

By varying the ratios of these three colors, we can create any color in the visible spectrum, but how do we tell all the millions of possible colors apart? We have definitive names for a few of them, sure, but when does one person’s interpretation of pumice [#78A489] end and blue fern [#759B84] begin?

We need some kind of universal language for defining colors. One that doesn’t leave any colors up to ambiguous interpretation. One that every modern device could conceivably understand and replicate. What we need are hex codes.

Greetings, Programs. Atari here, you there, and if you like learning about technology while building goofy projects around the shop, then go ahead and subscribe to this channel. Tally-ho!

Before we start talking about replicating colors, we should probably start by talking about how colors on a modern display are created. Most modern screens are made up of tiny picture elements–pixels–which are actually each made up of 3 color elements (or subpixels) that are each individually addressable.

Note that this is not the case when it comes to CRT displays. They employ an entirely different technology that we won’t be exploring in this video. If you want to learn about how CRT images are formed, Technology Connections has a fantastic piece all about it!

Anyway, pixels are each made up of 3 subpixels–one for each of the primary colors of light. By changing the intensity of each color’s respective subpixel, we can change the color of the pixel as observed by the human eye.

From red

To blue

To green

Or somewhere in between

Of course, if we turn everything up to full intensity, we’ll get white. Take everything down and we get black.

This is known as “additive color”: By adding more of a component color, we change the hue toward that component color.

Yes, this is a very rudimentary explanation of how additive color works, and I’m purposefully not going too in-depth because a discussion on color theory is really outside of the scope of this video. If you’re interested in that topic, leave me a note in the doobly-doo, and I’ll see what I can do. For now, I just want to provide a little context to facilitate the topic at hand.

Now, that brings me to the next point in this discussion. When we describe the capacity of a display to reproduce color information, we use a concept known as color depth. Color depth, or bit depth, is the number of bits used to indicate the color of a single pixel. As of 2018, nearly every display being manufactured is capable of displaying what’s known as “True Color” or 24-bit color. This means that every color the display is capable of reproducing can be defined by 24 bits or 3 bytes of information.

Are you still with me? Because this is where it all comes together.

Remember in the last video where we talked about how hexadecimal numbers work and why we use them in computing? You can watch the video up in the corner if you missed it.

Hexadecimal numbers work really well for computers because each digit holds 4 bits of information. If we put 2 hexadecimal digits together, we have a complete byte of information. That brings me back to these so-called “hex codes” for colors.

You may have noticed that hex codes are always six digits long. Six digits in hexadecimal is 3 bytes or 24 bits of information. So what do these codes mean? Let’s go back to 24-bit color.

We know that with 24 bit color, we have 3 bytes of color information. We also know that there are 3 primary colors of light represented by 3 subpixels in each pixel of the display. Are you starting to see a connection?

Now, you may–at some point–have seen a color indicated by an RGB value, a set of three numbers in parenthesis. This is a mathematical array that contains the respective intensities of the red, blue, and green subpixels. Each color’s intensity is represented by a decimal number between 0 and 255.

Why 255? Because it’s the largest decimal number that can be represented by 8 bits. That RGB value is actually a 24-bit number that’s written in an extremely clunky notation, but in engineering, we’re always looking for a way to make things more efficient. As such, we can fairly easily convert these three decimal numbers into three hexadecimal couplets and save quite a lot of typing down the road!

So in a hex code, each subpixel’s color is represented by a hexadecimal couplet: the first two digits are red, the next are blue, and the last two are green. By manipulating each couplet from double zero (zero intensity) to zero F (half intensity) to double F (full intensity), we can instruct a display to reproduce any of the 16 million 7 hundred 77 thousand 2 hundred 16 possible 24-bit colors.

Now for a fun fact: our squishy human eyes can only distinguish about 10 million different colors, so modern displays will actually reproduce more colors than we can possibly perceive, but those colors aren’t always evenly distributed across our perception space so some people will notice a phenomenon known as color banding at the transition between two adjacent colors. Light and perception is weird, man!

That, in a nutshell, is how hexadecimal codes work. Over the next several videos, I’ll be putting this information together with some electronics to build a rather interesting gadget, so be sure to subscribe and click the bell so you don’t miss out!

Connect with me on the social media and get sneak-peeks of projects in progress. Links are in the doobly-doo.

Up here is a video that YouTube thinks you’ll probably enjoy.

And the show notes for this episode are somewhere around here.

My name is Atari and until next time remember: It’s okay. It’s just a prototype.

Tally-ho, y’all!

How To Read Hexadecimal Numbers

Hexadecimal notation may look daunting, but with a little know-how and the right perspective, it can become extremely easy to learn how to read hex numbers. In this video, we’ll learn how to read hexadecimal numbers, how to count hexadecimal numbers, how to write hexadecimal numbers, and how to convert hexadecimal numbers.

Get the Arduino code, bill of materials, and more on element14.com/presents

Check out the rest of Project ColorTyme here

How To Train A Custom Wake Word For Google Assistant Using Snowboy

Following up to my primer on using Snowboy for custom Google Assistant wake words, in this video, I’ll walk you through using Snowboy’s “Hotword As A Service” to train your own wake words.

PARTS/TOOLS:

Google AIY Voice Kit

Raspberry Pi 3B+ (with appropriate SD card and power supply)

RESOURCES:

Snowboy

3D Printed Arduino Logo Wall Tile

Inspired by scouting merit badges, Atari decides to start a tile wall to celebrate his achievements. To celebrate building his first online course (Arduino For Kooks), he’s going to design a tile based on the Arduino Community Logo–a frenetic jumble of multicolored shapes forming the Arduino “infinity” logo. Since his 3D printer only has one extruder, he decides to paint and assemble the differently colored pieces for a nice, lo-fi aesthetic.

Download the STL files

Bill of materials:

Inland 2.85mm Silver PLA 3D Printer Filament

Craft Smart Acrylic Paint Value Set

Soldering Supercut: The RC2014 Homebrew Z80 Computer Kit (Long Play)

Assembling and soldering Grant Searle’s Z80 homebrew computer kit, the RC2014. This is a long-play video with no commentary. just some groovy tunes by the one-and-only Anders Enger Jensen. Sit back, grab a beverage, and chill to the vibes.

Watch the fully annotated video on element14: LINK
Check out more of Anders’s music here: https://www.youtube.com/user/HariboOSX

Mego 2XL Robot Teardown

The Mego 2XL Robot is an interesting piece from the very beginning of interactive electronic toys. The 1970s 2XL incorporated little more than a modified 8-track player to provide hours of entertainment on specially-formatted cassette tapes. In this Mego 2XL teardown, we’ll look at how the toy was built, the basic working mechanism, and attempt to diagnose a 2XL not working.

RESOURCES:

2XL Documents (contains US Patent and component data sheets)

How To Set Up OctoPi

I have a couple of new 3D printers that I need to build OctoPi servers for, so in this video, we’ll walk through how to set up OctoPi and attach it to most 3D printers.

OctoPi is available from OctoPrint.org

Etcher is available for Mac, Windows, and Linux at Balena.io

Benchy Quick Print by Thumper72 is available on Thingiverse

How To Use A Custom Wake Word With Google Assistant

The new voice assistants like Siri, Cortana, Alexa, and Google (itself?) are becoming more and more ubiquitous as we race toward a “Star Trek”-style omnipresent computing interface, but what if you don’t like invoking the name of your chosen corporate overlord when you use the assistant’s features? What if you could speak “Okay, Computer” into an Apple mouse like Scotty did? In this video, I’ll show you how to set up a custom wake word with your voice assistant using a platform called “Snowboy”.

 

PARTS/TOOLS:

Google AIY Voice Kit

Raspberry Pi 3B+ (with appropriate SD card and power supply)

RESOURCES:

Snowboy

Snowboy GitHub

GassistPi GitHub

How To Set Up Google AIY

How To Set Up Google Assistant On The Matrix Creator Development Board

Google Actions Console

Google Developer Console

How To Set Up Snowboy On Raspberry Pi:

Install the Sox, PortAudio, and PyAudio dependencies
sudo apt-get install python-pyaudio python3-pyaudio sox
pip install pyaudio

Install Swig by compiling from source
wget http://downloads.sourceforge.net/swig/swig-3.0.10.tar.gz
tar -xvf swig-3.0.10.tar.gz
sudo apt-get install libpcre3 libpcre3-dev
cd swig-3.0.10
./configure --prefix=/usr\
--without-clisp \
--without-maximum-compile-warnings &&

make
make install &&
install -v -m755 -d /usr/share/doc/swig-3.0.10 &&
cp -v -R Doc/* /usr/share/doc/swig-3.0.10

Install the Atlas library
sudo apt-get install libatlas-base-dev

Verify audio recording and playback work
arecord -f cd -d 5 test.wav
aplay test.wav

Clone the Snowboy repo
https://github.com/Kitt-AI/snowboy.git

Compile the Snowboy Python wrapper
cd snowboy/swig/Python
make

Run the Snowboy demo with the “Snowboy” wake word
cd snowboy/src/examples/Python
python demo.py /home/pi/snowboy/resources/models/snowboy.umdl

How To Set Up GassistPi On Google AIY:

Clone the GassistPi repo
git clone https://github.com/shivasiddharth/GassistPi

Install the AIY hat configuration
sudo chmod +x ./GassistPi/audio-drivers/AIY-HAT/scripts/configure-driver.sh
sudo ./GassistPi/audio-drivers/AIY-HAT/scripts/configure-driver.sh
sudo reboot
sudo chmod +x ./GassistPi/audio-drivers/AIY-HAT/scripts/install-alsa-config.sh
sudo ./GassistPi/audio-drivers/AIY-HAT/scripts/install-alsa-config.sh

Confirm that your audio still works
speaker-test -t wav

From here, you’re going to use the credentials as well as the project and device IDs created when you first set up the Google AIY kit. Refer to the how-tos above if you haven’t gotten this far yet.

Run the installer script (this will take a while)
sudo chmod +x ./GassistPi/scripts/gassist-installer.sh
sudo ./GassistPi/scripts/gassist-installer.sh

As the script finishes, you will be presented with a unique URL for authentication. Copy that URL into a browser, sign in to Google, copy the authentication code, and paste that at the prompt in the terminal.

You can now run Google Assistant via GassistPi which allows intricate customization options as well as custom wake words via Snowboy. Configure these options by using a text editor with ~/GassistPi/src/config.yaml

Run Google Assistant with the following command:
/home/${USER}/env/bin/python -u /home/${USER}/GassistPi/src/main.py --project_id [your project ID] --device_model_id [your device ID]

How To Set Up Google Assistant On The Matrix Creator Development Board

The Matrix Creator is an IoT-centric development board that comes with a wide array of goodies that facilitate hardware development such as an FPGA, various accelerometer and environmental sensors, IR transceivers, and even an 8-microphone array that can be used for echolocation as well as omnidirectional listening. It’s this microphone array that makes the Matrix Creator (and it’s smaller sibling, the Matrix Voice) an ideal platform for developing your own AI assistant! In this video, we’ll look at installing and setting up Google Assistant and see how it compares to the dedicated AIY hat from a previous video.

PARTS/TOOLS:

Raspberry Pi 3B+ (with appropriate SD card and power supply)

Matrix Creator

RESOURCES:

Matrix Labs GitHub

Installing the Matrix kernel modules:

Add the repository key
wget https://apt.matrix.one/doc/apt-key.gpg | sudo apt-key add -

echo "deb https://apt.matrix.one/raspbian $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/matrixlabs.list

sudo apt-get update
sudo apt-get upgrade

Install the packages
sudo apt install matrixio-creator-init

Reboot and install the kernel modules
sudo apt install matrixio-kernel-modules

Reboot and install the Google Assistant SDK per their instructions:

Now, you could run the Google Assistant at this point and everything will work just fine, but the fine folks at Matrix Labs actually put together a nice little application that adds color-changing lights and other little niceties to the stock Assistant installation

Clone the Matrix Google Assistant repo

git clone https://github.com/matrix-io/google-assistant-matrixio.git

Then run the program using the project and model IDs from the SDK setup
~/google-assistant-matrixio/google-matrixio-assistant-hotword --project_id [your-dev-project-id] --device_model_id [your-model-id]

Assistant will run and respond to the standard “OK, Google” or “Hey, Google” hotwords.

How To Set Up The Google AIY Voice Kit

AI voice assistants are the latest new hotness to come out of Silicon Valley, but before they were in every electronics department, they were much the exclusive playground of the DIY tinkerer. With kits like Google’s AIY line, hackers and makers can build their own voice assistants with little more than the good ol’ Raspberry Pi! In this video, I’ll walk you through how to set up the Google AIY Voice kit on a Raspberry Pi and run one of the demo python scripts to start building your own voice interfaces!

PARTS/TOOLS:

Google AIY Voice Kit

Raspberry Pi 3B+ (with appropriate SD card and power supply)

RESOURCES:

AIY Custom Raspbian http://aiyprojects.withgoogle.com/

Google Developer Console http://console.developers.google.com

Etcher

If you’re having trouble with segmentation faults crashing the Python demos, invoke these commands as Pi to install the earlier Google Assistant Library Python modules:

pip3 install google-assistant-library==1.0.0
pip3 install google-assistant-library

If you’re receiving the following error message

File "/home/pi/AIY-projects-python/src/aiy/assistant/auth_helpers.py", line 75, in _credentials_flow_interactive
webbrowser.register('chromium-browser', None, webbrowser.Chrome('chromium-browser'), -1)
TypeError: register() takes from 2 to 3 positional arguments but 4 were given

Then change line 75 in /home/pi/AIY-projects-python/src/aiy/assistant/auth_helpers.pyto the following:

webbrowser.register('chromium-browser', None, webbrowser.Chrome('chromium-browser'), preferred=True)

Be sure to keep the indentation and spacing the same as the original as it the code is sensitive.